0

I am developing a monitoring system with solar panel which involves to power on/off an Arduino through Raspberry Pi commands. The Arduino has a lot of sensors and I am using a command to switch on/off the raspi USB, so the arduino goes down and up. The problem is when the 'crontab' job wake up the USB power, the Arduino doesn´t send data through Serial. I need a help! See the steps bellow:

Arduino: Send data every 5 seconds when power on

Raspberry: Start power off USB at reload Every 20 min switch on USB, run service bellow for 30 seconds, stop this service and swicth off USB

import serial
import time

ser = serial.Serial('/dev/ttyACM0', 9600)
ser.flushInput()
ser.flushOutput()
while 1:
     line = ser.readline()
     items = line.split(',')

     print items
     f = open("/home/pi/data.txt","w")
     f.write("\t".join(items))
     f.close()
     time.sleep(1)
user1801745
  • 391
  • 2
  • 18
  • Are you sure that your arduino with all sensors consumes more power compared to RPI? I would worry about inability to put RPI into sleep mode. Did you consider to use arduino to control power of RPI instead of RPI controlling power of arduino? – Maxim Sagaydachny Mar 29 '21 at 16:14
  • Did you try waiting a while after powering up the Arduino before trying to talk to it? And even a further delay after opening the PySerial connection to it? – Mark Setchell Mar 29 '21 at 17:18

0 Answers0