reef-pi :: An opensource reef tank controller based on Raspberry Pi.

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Update, it boots up but I have no wireless connection, making an image so I can poke around some more at it but will probably just go with another fresh install and reload the backup configurations. Right now not sure what caused the update to go south, I have another older pi running same version of code and it updated fine, YMMV at the moment.

:)
 

ChrisNH

Active Member
View Badges
Joined
Mar 21, 2019
Messages
306
Reaction score
251
Rating - 0%
0   0   0
I am having trouble doing the "light" test in the adafruit guide 1. The first one, the on off light, works fine. However, I am having trouble defining a jack. When I create it I get:

{"error":"Failed to update. Error: write /sys/class/pwm/pwmchip0/pwm0/period: invalid argument"} | HTTP 500​

Checking the error log after trying to create the light as described in the tutorial I have:

Apr 12 10:45:19 reefpi reef-pi[334]: 2019/04/12 10:45:19 health check: Used memory: 10.44 Load5: 0.21
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 lighting-subsystem: Setting PWM value: 48 at channel: 0
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 Setting pwm driver: rpi pin: 0 value: 48
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument​

This pi came off a pi-cluster I was using for a distributed computing project so to troubleshoot I flashed it and ran through a clean install using the directions here:
https://reef-pi.github.io/general-guides/install/

There are a few slightly different versions of the install floating around. Perhaps I am missing something? And yes, I did add
dtoverlay=pwm-2chan

to the config.txt.

This is with reef-pi 2.3

One thing that was different.. the adafruit has me enabling 1-wire while the above did not. It does not have an effect on my current problem either way.

Thanks for your insight!
 

trackerit

Community Member
View Badges
Joined
Apr 11, 2019
Messages
71
Reaction score
137
Rating - 0%
0   0   0
Hi, I've been testing reefpi and it seems great, thanks to all the people that make this possible, I have the same problem when I add a jack, Failed to create error. Error: write / sys / class / pwm / pwmchip0 / pwm0 / period: invalid argument "
Has any solution been found?
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I am having trouble doing the "light" test in the adafruit guide 1. The first one, the on off light, works fine. However, I am having trouble defining a jack. When I create it I get:

{"error":"Failed to update. Error: write /sys/class/pwm/pwmchip0/pwm0/period: invalid argument"} | HTTP 500​

Checking the error log after trying to create the light as described in the tutorial I have:

Apr 12 10:45:19 reefpi reef-pi[334]: 2019/04/12 10:45:19 health check: Used memory: 10.44 Load5: 0.21
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 lighting-subsystem: Setting PWM value: 48 at channel: 0
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 Setting pwm driver: rpi pin: 0 value: 48
Apr 12 10:45:49 reefpi reef-pi[334]: 2019/04/12 10:45:49 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument​

This pi came off a pi-cluster I was using for a distributed computing project so to troubleshoot I flashed it and ran through a clean install using the directions here:
https://reef-pi.github.io/general-guides/install/

There are a few slightly different versions of the install floating around. Perhaps I am missing something? And yes, I did add
dtoverlay=pwm-2chan

to the config.txt.

This is with reef-pi 2.3

One thing that was different.. the adafruit has me enabling 1-wire while the above did not. It does not have an effect on my current problem either way.

Thanks for your insight!
Can you reload reef-pi and see if the error happens again ? This happens when you update the pwm frequency and not rebooted pi after that
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
Hi, I've been testing reefpi and it seems great, thanks to all the people that make this possible, I have the same problem when I add a jack, Failed to create error. Error: write / sys / class / pwm / pwmchip0 / pwm0 / period: invalid argument "
Has any solution been found?
Welcome to reef2reef. Can you try rebooting pi and see if the error persist? I just shared some details on why this may happen sometime
 

Bzar

Community Member
View Badges
Joined
Apr 11, 2019
Messages
32
Reaction score
66
Rating - 0%
0   0   0
Having some issues getting float switch to work. I've followed the circuit diagram here with the COM having a 10K and 1K on the Pin line. Then the NO straight to GND. But some reason it's just not picking up the switch on any pin. I've restarted, rewired, tried different pins, tested the switch, tried other switches, etc. Could it be impedance in the wires of my floats? Should I just use the pull_up resistors on the pi zero?

If I were to try that I was thinking of just making a python script to activate the resistors with a script like this then just use that pin on the inlet for the float?? Then I wouldn't need 3 wires to float also I guess?

#floatswitch1.py
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

#GPIO Pin of switch
floatPin1 = 21

GPIO.setup(floatPin1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
 

trackerit

Community Member
View Badges
Joined
Apr 11, 2019
Messages
71
Reaction score
137
Rating - 0%
0   0   0
Welcome to reef2reef. Can you try rebooting pi and see if the error persist? I just shared some details on why this may happen sometime

thanks for the welcome, I have reboot the rasberry and the problem continues, is this only for the raspberry pwm? If I put the PCA9685, will I have the same problem?

Apr 12 12:11:38 raspberrypi reef-pi[339]: 2019/04/12 12:11:38 Setting pwm driver: rpi pin: 0 value: 81
Apr 12 12:11:38 raspberrypi reef-pi[339]: 2019/04/12 12:11:38 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument
 

ChrisNH

Active Member
View Badges
Joined
Mar 21, 2019
Messages
306
Reaction score
251
Rating - 0%
0   0   0
I restarted the pi, log shows
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 lighting-subsystem: Setting PWM value: 48 at channel: 0
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 Setting pwm driver: rpi pin: 0 value: 48
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument​

So no discernable change. If I edit and save the jack again I still get
{"error":"Failed to update. Error: write /sys/class/pwm/pwmchip0/pwm0/period: invalid argument"} | HTTP 500​
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I restarted the pi, log shows
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 lighting-subsystem: Setting PWM value: 48 at channel: 0
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 Setting pwm driver: rpi pin: 0 value: 48
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument​

So no discernable change. If I edit and save the jack again I still get
{"error":"Failed to update. Error: write /sys/class/pwm/pwmchip0/pwm0/period: invalid argument"} | HTTP 500​

Welcome! :)

Did you follow the initial setup instructions here - https://learn.adafruit.com/reef-pi-installation-and-configuration/raspberry-pi-configuration

Specifically this section:
Code:
reef-pi uses Raspberry Pi's hardware timers for PWM (used for LED dimming, DC 
motor control etc.). This allows reef-pi to use up to two PWM channels without any ancillary
electronics. This feature is only available in newer Linux kernels (4.9 and above). We have to
edit /boot/config.txt file and add this line at the end to enable (then reboot)

dtoverlay=pwm-2chan

Once you do that you need to reboot and see if that helps, you can control the frequency of the pi pwm from the configuration page.
 

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
Since my update went sideways, I took this opportunity to create a restoration process, it's not exactly step by step but its pretty close and should allow you to restore to a clean image of Raspbian and restore reef-pi to your last working configuration. If anyone see's any additional steps or clarification needed please let me know, I am still planning on working on some simple scripts to routinely backup the needed files for reef-pi restoration.

One note, this also has me disabling the user pi and disabling login, you can change or add to what I have here, this is just my rpi initial configuration.

Woot :) :)

Code:
Rasbian information Headless setup:

Pre-work:

*Download latest raspbian version that you want to use and install to SD card - https://www.raspberrypi.org/downloads/raspbian/

*WPA_Supplicant - file created in /boot

      ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
      update_config=1
      country=US

      network={
         ssid="War_Eagle_2g"
         scan_ssid=1
         psk="Insert-PSK"
         key_mgmt=WPA-PSK
      }

*Create empty file in /boot called "ssh" (enables SSH on first boot)

*SSH to pi
        username:pi
        password:raspberry
 ****Change password******(cmd passwd)

*adduser account (/home/"user")
*add new user to sudoers (cmd sudo usermod -aG sudo username)
*add new user to same groups as "pi" user
    (cmd display groups - pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi)
    (cmd usermod -a -G pi,adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi,username)
*disable pi user login (sudo vi /etc/passwd, change user pi to pi:x:1000:1000:,,,:/home/pi:/usr/sbin/nologin)
*change hostname (cmd hostname tankpi, sudo vi /etc/hosts, sudo vi /etc/hostname)
*set timezone (cmd raspi-config or sudo timedatectl set-timezone America/Chicago or America/<insert city>)
*Install reef-pi (cmd dpkg -i reef-pi-2.2-pi3.deb
                 (cmd sudo sudo systemctl stop reef-pi.service)
                 (cmd sudo mv /var/lib/reef-pi/reef-pi.db /var/lib/reef-pi/reef-pi.org)
                 (cmd sudo cp reef-pi.db /var/lib/reef-pi/.)
                 (cmd sudo systemctl start reef-pi.service)


Enjoy!
 
Last edited:

bishoptf

Valuable Member
View Badges
Joined
Jan 1, 2019
Messages
1,409
Reaction score
1,726
Location
Missouri
Rating - 0%
0   0   0
I restarted the pi, log shows
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 lighting-subsystem: Setting PWM value: 48 at channel: 0
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 Setting pwm driver: rpi pin: 0 value: 48
Apr 12 17:03:20 reefpi reef-pi[314]: 2019/04/12 17:03:20 ERROR: lighting-subsystem: Failed to set pwm value. Error: write /sys/class/pwm/pwmchip0/pwm0/duty_cycle: invalid argument​

So no discernable change. If I edit and save the jack again I still get
{"error":"Failed to update. Error: write /sys/class/pwm/pwmchip0/pwm0/period: invalid argument"} | HTTP 500​

I missed the above information, you stated that you re-flashed the rpi, is it using the latest raspbian version? Just thinking about what else it could be, I use the PWM to drive 2 of my lights, and that dtoverlay command only works with kernels 4.9 and above. I will see what else it could be but that error looks like PWM is not enabled.
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I missed the above information, you stated that you re-flashed the rpi, is it using the latest raspbian version? Just thinking about what else it could be, I use the PWM to drive 2 of my lights, and that dtoverlay command only works with kernels 4.9 and above. I will see what else it could be but that error looks like PWM is not enabled.
His dtoverlay configuration is already in place (else he'll get a different error, that /sys/class/pwm.. file wont be present). I suspect the pwm frequency is set to some bad values (check Configuration -> Settings -> pwm settings and set it to a higher value [say 1000]) , reboot and see what happens
 

Bzar

Community Member
View Badges
Joined
Apr 11, 2019
Messages
32
Reaction score
66
Rating - 0%
0   0   0
Having some issues getting float switch to work. I've followed the circuit diagram here with the COM having a 10K and 1K on the Pin line. Then the NO straight to GND. But some reason it's just not picking up the switch on any pin. I've restarted, rewired, tried different pins, tested the switch, tried other switches, etc.


So I took some time and figured out how to use regular float switches in a simple fashion using the built in pi resistors. This makes me happy because I don't have to have extra wiring and soldering tasks when adding a bunch of switches, and I don't have to pay for something I already bought. So to get regular float switches (or any switches for that matter) working safely you can do this...

Step A) create a python script to control the pull up resistance. From the terminal...

sudo nano switches.py

#switches.py
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)

ctrl+X > Y > <enter>

Step B) make the file executable...

sudo chmod 755 switches.py

Step C) make the script run at startup by adding a line just before "exit" in rc.local (note: the python start command must point to the directory from root /...

sudo nano /etc/rc.local

sudo python /home/pi/switches.py &

ctrl+X > Y > <enter>

Step D) Restart or Reboot

sudo reboot

Step E) Plug your float switch wires into the GPIO. One wire to Pi header connected Ground, and one to the GPIO you used in switches.py

Step F) Check to see if your script is running...

ps -aef | grep python

Step G) Designate those pins in Reef-Pi to inlets/ATO for your application.

Hope this helps, working for me here.
 

trackerit

Community Member
View Badges
Joined
Apr 11, 2019
Messages
71
Reaction score
137
Rating - 0%
0   0   0
His dtoverlay configuration is already in place (else he'll get a different error, that /sys/class/pwm.. file wont be present). I suspect the pwm frequency is set to some bad values (check Configuration -> Settings -> pwm settings and set it to a higher value [say 1000]) , reboot and see what happens
Hi, I have tried placing the frequency in 1000 I have rebooted the raspberry, and even I have turned it off, it does not work, you can look it in http://200.124.25.203 the credentials are by default
 

trackerit

Community Member
View Badges
Joined
Apr 11, 2019
Messages
71
Reaction score
137
Rating - 0%
0   0   0
hi again
uname -a show (Linux raspberrypi 4.14.98-v7 + # 1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU / Linux) my version of the kernel is 4.14 )
and I have read that it must be greater than 4.9, but I have updated the kernel version and it tells me that the last one is 4.19. Could you help me to know what I'm doing wrong? update the kernel rpi-update
 
OP
OP
Ranjib

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,876
Reaction score
16,680
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
hi again
uname -a show (Linux raspberrypi 4.14.98-v7 + # 1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l GNU / Linux) my version of the kernel is 4.14 )
and I have read that it must be greater than 4.9, but I have updated the kernel version and it tells me that the last one is 4.19. Could you help me to know what I'm doing wrong? update the kernel rpi-update
I don’t think there’s any issue with your pi or raspbian version, can you share a screenshot of you reef-pi configuration /settings page ?
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 38 26.6%
  • 100% dry rock + 100% live sand

    Votes: 48 33.6%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 32 22.4%
  • 75% live rock, 25% live sand

    Votes: 15 10.5%
  • 25% live rock, 75% live sand

    Votes: 10 7.0%
Back
Top