Python Forum
Arduino Uno connected to PI 0 W - Sensor Data MQTT
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino Uno connected to PI 0 W - Sensor Data MQTT
#3
Why would you need Putty? Don't they communicate fine without?

Arduino Sketch:
const int ledPin = 13
void setup()
{
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
void loop()
{
  Serial.println("Hello Pi");
  if (Serial.available())
  {
  flash(Serial.read() - '0');
  }
  delay(1000);
}
void flash(int n)
{
  for (int i = 0; i < n; i++)
  {
    digitalWrite(ledPin, HIGH);
    delay(100);
    digitalWrite(ledPin, LOW);
    delay(100)
Raspberry Code:
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
  print(ser.readline())
And to send from Raspberry to Arduino:
ser.write('5'.encode())
I would think that there must be tons of people out there who are pulling sensor data from an Arduino via a Pi, so I was just interested in their approach.
Reply


Messages In This Thread
RE: Arduino Uno connected to PI 0 W - Sensor Data MQTT - by runboy - Nov-05-2018, 01:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to check if Skype call is connected or disconnected in Python? boral 1 445 Dec-28-2023, 08:31 AM
Last Post: buran
  add mqtt feature to existing code Positron79 0 612 Jan-31-2023, 05:56 PM
Last Post: Positron79
  Trying to Get Arduino sensor data over to excel using Python. eh5713 1 1,771 Dec-01-2022, 01:52 PM
Last Post: deanhystad
  When is stdin not connected to a tty, but can still be used interactively? stevendaprano 1 1,046 Sep-24-2022, 05:06 PM
Last Post: Gribouillis
  Mqtt Shiri 0 1,313 Dec-07-2021, 02:01 PM
Last Post: Shiri
  Paho-mqtt fully supports MQTT 5.0 protocol? nitinkothari17 0 1,584 Jan-12-2021, 11:14 AM
Last Post: nitinkothari17
  Printing to a printer connected to pi 4 alan 2 2,510 Oct-04-2020, 10:08 PM
Last Post: alan
  Save Arduino data in mysql server via raspberrypi rithikvg 1 3,454 Jun-24-2020, 10:59 PM
Last Post: Larz60+
  Help Graphing Arduino Data Real Time in Python nschulz 0 2,572 Mar-12-2020, 06:15 PM
Last Post: nschulz
  Create sensor data for a IoT project georgelza 9 5,969 Dec-20-2019, 06:19 PM
Last Post: georgelza

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020