Arduino Uno Serial Raspberry Pi4B

Raspberry Pi4B serial to Arduino Uno

Goal: direct upload of data from arduino uno using internet from raspberry pi…Is that possible?

The library in arduino for influxdb uses esp wlan module…

Currently Iam able to readout utf-8.rstrip() from arduino with python script over raspberry. but i guess that format wont be fit in influxdb easily…

Any thoughts?


measuring wind temp press rhum

I had the same setup once before I moved it to ESP.
Just send numbers from UNO, without units (e.g. comma separated), and you will be ok with ASCII chars.
You can use InfluxDB Python client to write data.

import serial
import time
from influxdb import InfluxDBClient
import urllib3


urllib3.disable_warnings()
ser=serial.Serial("/dev/ttyUSB0",9600)  #change ACM number as found from ls /dev/tty/ACM*
ser.baudrate=9600

client = InfluxDBClient(server,8086,user,password, database, True, False)

while True:
  read_ser=ser.readline()

  data=read_ser.strip().split(",")
  print(data)
  if len(data) == 3:
    json_body=[
     {
       "measurement":"air",
       "tags": {
          "location":location
       },
       "fields": {
         "temp":float(data[0]),
         "hum":float(data[1]),
         "co2":float(data[2])
       }
    }
    ]
    client.write_points(json_body)
  if len(data) == 1:
    json_body=[
     {
       "measurement":"air",
       "tags": {
          "location":location
       },
       "fields": {
         "co2":float(data[0])
       }
    }
    ]
    client.write_points(json_body)
1 Like

dude sorry for the late response. thanks for your help.

thats my output now

Is your code fore arduino? (.ino?)
how to i get the datfor server, database etc?

The example I’ve provided above is python code running on raspberry using Python client for InfluxDB 1x.
It reads data from the virtual serial driver which is loaded when Arduino is connected via USB cable to Raspberry Pi.
It reads lines and splits each row into values by the comma char. As you are using a semi-colon as a separator char, you need to modify it.
Split data is written to the database via JSON payload used by the python client.

Ahh great got it. My goal is to use the influxdb cloud service.

I created a bucket there. Did you the same?

My code was used at the time when there was only InfluxDB 1, so it is using the client for v1. You can easily use examples as you posted above to adjust code to write data to InfluxDB 2 Cloud. When you parse lines into an array of strings, you can use those parts to fill Point.

I would recommend you to first try the examples without data from Arduino to make sure your code to write data works ok, then add code to read and parse Arduino measurements.