freenove / freenove_ultimate_starter_kit_for_raspberry_pi Goto Github PK
View Code? Open in Web Editor NEWApply to FNK0020
License: Other
Apply to FNK0020
License: Other
Hi, I get the follwing issue in Chapter 8 "Potentiometer & LED" :
pi@raspberrypi:~/freenove/ultimate/Code/Python_Code/08.1.1_Softlight/ python Softlight.py
Traceback (most recent call last):
File "Softlight.py", line 13, in
bus=smbus.SMBus(1)
FileNotFoundError: [Errno 2] No such file or directory
I've found SMBus can be set to 0 but doesn't solve the problem.
The destroy method seems to be missing these two function calls (compared to previous chapters):
p.stop()
GPIO.cleanup()
Or is there a reason why these are not needed in this example?
Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory a/g: 512 0 0 0 0 0 a/g: 0.03 g 0.00 g 0.00 g 0.00 d/s 0.00 d/s 0.00 d/s Failed to open device: No such file or directory
Python does bugger all.
On the project 02.2.1_Tablelamp, after executing "python Tablelamp.py", press the button (so the led will be on), then stop the program. If the program is executed again the led will turn on automatically when is supposed to be off, because if the button is pressed the first action is turn on the led and anything will happen because the led is already on.
Hi All,
I tried following circuit, basically I want GPIO connection without any need of relay or speed control. But apparently attached circuit never worked. Am I missing something ?, can you please help me on the same..
I see only 2 circuit with motor present.
I don't want either, mine should basically start with just transitior.
Hi All,
I see the LCD project (20) just switches on the LCD but I don't see any display on the same. Please let me know if there is any change to be done in the script..
-Balaji Kamal Kannadassan
Hi, I am a novice programmer trying to achieve the following by combining the codes for the projects 13.1 Control a DC Motor with a Potentiometer and Project 20.1 I2C LCD1602 to have the I2C LCD display the speed that is shown on the terminal window when executing the project 13.1.
I've attached a code to first display the time while running the motor with a potentiometer but I can't get the code to compile... Can anyone guide me to achieve this? and teach me what I am doing wrong?
-------- Code ---------------
#include <wiringPi.h>
#include <wiringPiI2C.h>
#include <stdio.h>
#include <stdlib.h>
#include <softPwm.h>
#include <math.h>
#include <stdlib.h>
#include <ADCDevice.hpp>
#include <pcf8574.h>
#include <lcd.h>
#include <time.h>
int pcf8574_address = 0x27; // PCF8574T:0x27, PCF8574AT:0x3F
#define BASE 64 // BASE any number above 64
//Define the output pins of the PCF8574, which are directly connected to the LCD1602 pin.
#define RS BASE+0
#define RW BASE+1
#define EN BASE+2
#define LED BASE+3
#define D4 BASE+4
#define D5 BASE+5
#define D6 BASE+6
#define D7 BASE+7
#define motorPin1 2 //define the pin connected to L293D
#define motorPin2 0
#define enablePin 3
ADCDevice *adc; // Define an ADC Device class object
//Map function: map the value from a range to another range.
long map(long value,long fromLow,long fromHigh,long toLow,long toHigh){
return (toHigh-toLow)*(value-fromLow) / (fromHigh-fromLow) + toLow;
}
//motor function: determine the direction and speed of the motor according to the ADC
void motor(int ADC){
int value = ADC -128;
if(value>0){
digitalWrite(motorPin1,HIGH);
digitalWrite(motorPin2,LOW);
printf("turn Forward...\n");
}
else if (value<0){
digitalWrite(motorPin1,LOW);
digitalWrite(motorPin2,HIGH);
printf("turn Back...\n");
}
else {
digitalWrite(motorPin1,LOW);
digitalWrite(motorPin2,LOW);
printf("Motor Stop...\n");
}
softPwmWrite(enablePin,map(abs(value),0,128,0,100));
printf("The PWM duty cycle is %d%%\n",abs(value)*100/127);//print the PMW duty cycle
}
int lcdhd;// used to handle LCD
void printDataTime(){//used to print system time
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);// get system time
timeinfo = localtime(&rawtime);//convert to local time
printf("%s \n",asctime(timeinfo));
lcdPosition(lcdhd,0,1);// set the LCD cursor position to (0,1)
lcdPrintf(lcdhd,"Time:%02d:%02d:%02d",timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); //Display system time on LCD
}
int detectI2C(int addr){
int _fd = wiringPiI2CSetup (addr);
if (_fd < 0){
printf("Error address : 0x%x \n",addr);
return 0 ;
}
else{
if(wiringPiI2CWrite(_fd,0) < 0){
printf("Not found device in address 0x%x \n",addr);
return 0;
}
else{
printf("Found device in address 0x%x \n",addr);
return 1 ;
}
}
}
int main(void){
int i;
printf("Program is starting ...\n");
wiringPiSetup();
if(detectI2C(0x27)){
pcf8574_address = 0x27;
}else if(detectI2C(0x3F)){
pcf8574_address = 0x3F;
}else{
printf("No correct I2C address found, \n"
"Please use command 'i2cdetect -y 1' to check the I2C address! \n"
"Program Exit. \n");
return -1;
}
pcf8574Setup(BASE,pcf8574_address);//initialize PCF8574
for(i=0;i<8;i++){
pinMode(BASE+i,OUTPUT); //set PCF8574 port to output mode
}
digitalWrite(LED,HIGH); //turn on LCD backlight
digitalWrite(RW,LOW); //allow writing to LCD
lcdhd = lcdInit(2,16,4,RS,EN,D4,D5,D6,D7,0,0,0,0);// initialize LCD and return “handle” used to handle LCD
if(lcdhd == -1){
printf("lcdInit failed !");
return 1;
}
while(1){
printDataTime(); // print system time
delay(1000);
}
return 0;
adc = new ADCDevice();
printf("Program is starting ... \n");
if(adc->detectI2C(0x48)){ // Detect the pcf8591.
delete adc; // Free previously pointed memory
adc = new PCF8591(); // If detected, create an instance of PCF8591.
}
else if(adc->detectI2C(0x4b)){// Detect the ads7830
delete adc; // Free previously pointed memory
adc = new ADS7830(); // If detected, create an instance of ADS7830.
}
else{
printf("No correct I2C address found, \n"
"Please use command 'i2cdetect -y 1' to check the I2C address! \n"
"Program Exit. \n");
return -1;
}
wiringPiSetup();
pinMode(enablePin,OUTPUT);//set mode for the pin
pinMode(motorPin1,OUTPUT);
pinMode(motorPin2,OUTPUT);
softPwmCreate(enablePin,0,100);//define PMW pin
while(1){
int value = adc->analogRead(0); //read analog value of A0 pin
printf("ADC value : %d \n",value);
motor(value); //make the motor rotate with speed(analog value of A0 pin)
delay(100);
}
return 0;
}
Sorry i just wrote this in the wrong place but i am trying to run the code but i get a GPIO error.
Pls Help
when i put in the code "git clone --depth 1 https://github.com/freenov/Freenov_Super_Starter_Kit_for_Raspberry_Pi" and press enter its asking for a username for github ive tried my own but it doesnt work and i tried just not using a user name and pass word but it doesnt like it either need help asap
Might be good to document the supported version(s) somewhere.
Might even be worth considering to create a separate git branch for each supported version (in case parts of the code do not work on all versions). Although this would probably require also separating each programming language to it's own repository.
Just some food for thought.
The amazon store title said there were 434 pages of detailed instructions https://www.amazon.de/-/nl/gp/product/B06W54L7B5/ref=ppx_yo_dt_b_asin_title_o04_s00?ie=UTF8&psc=1
The tutorial.pdf only contains 314 pages.
Is this the correct repo for the Raspberry pi 4?
Both example codes in the DHT11 have the line: chk = dht.readDHT11(DHTpin)
but in the DHT11 library, the readDHT11() function doesn't take a pin input, throwing an argument error. It should be corrected to: chk = dht.readDHT11()
.
The code supplied for the DHT11 lesson does not have this error, they run fine.
Do you have also the Java code for this starter kit ?
Helping at an electronics summer camp and were using this kit to get the kids introduced to the raspberry pi. For the past week, we've been telling the kids to just skip over any circuit that requires this chip (all of the analog input circuits). offloaded the task of figuring out why the circuit wasn't working to a proper electrical engineer and he found that the PCF8591 that shipped with our kit has its pins mirrored so each and every chapter was incompletable.
to fix this just mirror the pinouts for this chip (not rotate, mirror)
hi
I'm not sure where my issues should go but I need help with a command prompt. I am on the first tutorial labeled as blink. The issue that I'm having is when I type in cd ~/Freenove_Kit/Code/C_Code/01.1.1_Blink . The only message I get is "there is no such file or directory". I followed the above steps where I had to download the latest version of wiringpi and that all went smooth and updated. I looked through the files on the pi and have found the location of blink file. I'm not sure if its a corrupt file or if I'm doing something wrong. I've typed that line of code in like 10 times and received the same message ever time.
In Acceleration detection sketch wrt MPU6050 sketch 27.1
at line 10
MbedI2C iic(6,7);
Get compilation error 'MbedI2C' does not name a type
Seems another library needs to be referenced.
I was working on the LightWater project and when I tried to input the python code I got the message...
"Program is starting (which is the only action I got when I did the C code, no other error, no lights, just program is starting)
Traceback (most recent call last):
File "lightwater.py", line 37 in module
setup ()
file "lightwater.py", line 17 in setup
GPIO. setup (pin GPIO out set all ledpins mode is output
Runtime error no access to dev/mem. Try running as root.
I've also had issues with the led blink with button chapter as well. The error was saying no directory or file, even though I can clearly see it in the folder manager.
Any suggestions?
Hey guys,
Playing with the RGB LED and it seems that the values are backwards?
To light one of the colours instead of a value of say 100, I have to use a value of 0.
Safe to say the random values make the colours look pretty awful as a result.
Is this correct?
Thanks
Andrew
I cannot find instructions or a way to install python libraries ADCDevice-1.0.2 & ADCDevice-1.0.3 I have tried usual pip and pip3 install instructions but ADCDevice-1.0.2 is not found.
Hello,
When running the C code for chapter 14 everything works as expected. When running the Python code, the button has a duplicate event after the bouncetime
. I was wondering if I was the only person to experience this behavior.
I modified the code as follows (see sections titled ### New code to test duplicate events
) and for 10 seconds I see ~33 Skipping button press...
output lines (corresponding to the bounce time of 300 and the 10 second ignore).
I've got a RPi 3 B+. Thanks for any insight you might be able to provide.
#!/usr/bin/env python3
########################################################################
# Filename : Relay.py
# Description : Button control Relay and Motor
# Author : freenove
# modification: 2018/08/02
########################################################################
import RPi.GPIO as GPIO
from datetime import datetime, timedelta
relayPin = 11 # define the relayPin
buttonPin = 12 # define the buttonPin
relayState = False
### New code to test duplicate events:
lastEventTime = datetime.now() - timedelta(seconds=10)
### End new code.
def setup():
print ('Program is starting...')
GPIO.setmode(GPIO.BOARD) # Numbers GPIOs by physical location
GPIO.setup(relayPin, GPIO.OUT) # Set relayPin's mode is output
GPIO.setup(buttonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Set buttonPin's mode is input, and pull up to high
def buttonEvent(channel):
global relayState
### New code to test duplicate events:
global lastEventTime
print ('buttonEvent GPIO%d'%channel)
if lastEventTime + timedelta(seconds=10) > datetime.now():
print('Skipping button press...')
return
lastEventTime = datetime.now()
### End new code.
relayState = not relayState
if relayState :
print ('Turn on relay ... ')
else :
print ('Turn off relay ... ')
GPIO.output(relayPin,relayState)
def loop():
#Button detect
GPIO.add_event_detect(buttonPin, GPIO.FALLING, callback=buttonEvent, bouncetime=300)
while True:
pass
def destroy():
GPIO.output(relayPin, GPIO.LOW) # relay off
GPIO.cleanup() # Release resource
if __name__ == '__main__': # Program start from here
setup()
try:
loop()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed, the child program destroy() will be executed.
destroy()
Output looks like this with a single button push:
Program is starting...
buttonEvent GPIO12
Turn on relay ...
buttonEvent GPIO12
Skipping button press...
buttonEvent GPIO12
Skipping button press...
...
buttonEvent GPIO12
Turn off relay ...
If I unplug the motor, there aren't any duplicate events.
Hi, I have been using your python code to code my own stuff. After all of that I was like: "It would be a great idea to try to learn C/C++". So I did that but when I installed WiringPI and ran gpio -v it said :" No Hardware Line in /proc/cpuinfo"( i was removed for later kernels as it was unreliable. I thought it wasn't a big deal until I read that you need to have that line. So I started to see if you can bypass that but you can't. I was pretty disappointed. So I started searching for an alternative. I found one named pigpio Which was a good library, but there is one problem. It does not support the old WiringPI code. I did try to re-code some stuff but I was only able to code the 01.1.1 blink code to work. At this point I gave up and stayed using python. So would it be possible that you update your guides(every guide you have as they all have that same error) to use pigpio or some other lib for gpio usage in C/C++ code.
Thank you
Thom
My Commands:
git clone https://github.com/WiringPi/WiringPi
cd WiringPi/
./build
Error:
sudo: make: command not found
Fix:
sudo apt-get update
sudo apt-get install make
sudo apt-get install gcc
mcp.output(3,1) # turn on LCD backlight
Is used to turn the backlight on ... how do I actually turn the backlight off?
mcp.output(3,0)
does not work
Or am I using the wrong pin number?
In the Python example code for the Joystick Lesson there's a line of code leftover from the RGBLED lesson.
First line following the setup() function
global p_Red,p_Green,p_Blue
It doesn't affect how the script runs, but it doesn't belong.
The circuit in chapter 24 connects the Echo pin of the HC-SR04 (which runs at 5V) directly to the Pi. Since the Pi’s GPIO pins are not 5V-tolerant, this runs the risk of damaging the Pi.
A fix is to put a 1K resistor between Echo and GPIO24, then connect two 1K resistors in series between GPIO24 and GND, creating a voltage divider to bring the input to a safe level.
I tried to follow the instructions on chapter 23 - Infrared Motion Sensor, but it was not working. The led kept turning on and off indefinitely. I did some research and found that the sensor needs an input voltage between 4.5 and 20 volts, and found this Raspberry tutorial that suggests the sensor should be connected to the 5v pin. In the tutorial pdf, however, you say that it should be connected to 3.3v. After changing it to 5v, the code worked flawlessly!
You should probably also tell people to adjust the time delay potentiometer to short responses (counter clockwise), as this will make the led more responsive (and it is probably what people expect to see at first)
Only change to program per instructions is setting PCF 8574_address as shown on page 207 Number 2.
main': I2CLCD1602.c:(.text+0x178): undefined reference to
wiringPiSetup'pcf8574Setup' I2CLCD1602.c:(.text+0x1c0): undefined reference to
pinMode'digitalWrite' I2CLCD1602.c:(.text+0x1f0): undefined reference to
digitalWrite'delay' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
digitalRead'wiringPiI2CSetup' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
sn3218Setup'delayMicroseconds' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
analogWrite'digitalWriteByte' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
wiringPiSPIDataRW'wiringPiSPISetup' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
pullUpDnControl'wiringPiNewNode' /usr/lib/gcc/arm-linux-gnueabihf/6/../../../libwiringPiDev.so: undefined reference to
mcp23s17Setup'if I remove "Dev" from end:
$ gcc I2CLCD1602.c -o I2CLCD1602 -lwiringPi
/tmp/ccUZNFFi.o: In function printCPUTemperature': I2CLCD1602.c:(.text+0x78): undefined reference to
lcdPosition'
I2CLCD1602.c:(.text+0x94): undefined reference to lcdPrintf' /tmp/ccUZNFFi.o: In function
printDataTime':
I2CLCD1602.c:(.text+0x120): undefined reference to lcdPosition' I2CLCD1602.c:(.text+0x150): undefined reference to
lcdPrintf'
/tmp/ccUZNFFi.o: In function main': I2CLCD1602.c:(.text+0x24c): undefined reference to
lcdInit'
collect2: error: ld returned 1 exit status
For the C code, Project 20, I2C LCD1602, the time is displayed incorrectly.
localtime() returns a struct where seconds, minutes and hours can be a single digit if the value is less than 10.
int tm_sec; /* seconds, range 0 to 59 */
int tm_min; /* minutes, range 0 to 59 */
int tm_hour; /* hours, range 0 to 23 */
When ticking, the LCD do not reset itself and displays a wrong time when passing over a minute.
eg:
23:15:58
23:15:59
23:16:19
23:16:29
...
23:16:99
23:16:10
23:16:11
Tutorial, page 143 (python code):
"We need to use the map () subfunction mapping the difference value to range of 0-255. "
Should be:
"We need to use the map () subfunction mapping the difference value to range of 0-100. "
Because in the code we have :
p.start(mapNUM(abs(value),0,128,0,100))
In task 3.1.1 with the GPIOZero pdf, it should import and use LEDBoard
and not LEDBarGraph
I was looking at the C version of the Relay and Motor code and noticed that if I increase captureTime to 1 sec (long captureTime = 1000), then it becomes impossible to turn off the motor. It's happening because when the motor is running, it is almost impossible for the button to stay in the LOW state for a few hundred milliseconds even if it's being firmly pressed down all the time. It can be easily seen by printing a debug line when reading == HIGH. The schematic diagram and the code are the latest as of Oct 29, 2018.
The problem seems to be similar to one in issue #7 . There is an easy fix though, just adding a capacitor 0.1 uF aka "104" between "+" and "-" of the power supply makes spurious state transitions much less frequent.
So to summarize, the code works as it is now, but adding a capacitor (which is included in the set) makes the system more robust. Just wanted to share this observation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.