-2

I am trying to send a 16x2 LCD output to a remote RPi wirelessly using python code. I am having difficulty finding information online about this and am wondering if any of you could help me. I am very new to python and RPis.

Background on project: I have a Pi0 reading a water level sensor using an ADC. I currently also have this Pi0 outputting the level of the water on a 16x2 LCD screen that it connected to the Pi0.

Goal: I want to have this 16x2 LCD output sent to a separate remote Pi1 wirelessly.

  • Do you mean that you want to send 1 or 0 wirelessly to LCD connected to an RPI ? – LazyCoder Jul 26 '19 at 21:00
  • I am confused on the question you're asking. I am very new to this stuff. – BlazeDakota Jul 26 '19 at 21:03
  • 1
    You say you want to send *"an LCD output"*. What do you actually want to send - an image or a number? You say you want to send wirelessly. Do you mean wifi, or Bluetooth or something else? – Mark Setchell Jul 26 '19 at 21:03
  • I am using a 16x2 LCD. I want to send a string and a variable collected from the water level sensor to the LCD. Over WiFi preferably but Bluetooth is also an option – BlazeDakota Jul 26 '19 at 21:05
  • O you mean marquee a string on LCD screen. Could you edit the question to reflect that? – LazyCoder Jul 26 '19 at 21:08
  • Based on the thread, it sounds like you want to collect sensor data on Pi0 and then have Pi1 display that data on a LCD Screen. If these are on the same WiFi network, I would suggest doing it like an API Call. Pi0 will be a small web server and can take HTTP GET/POST requests that will return the sensor data in JSON, XML ,String ... whatever. Pi1 can then use Python or whatever to make the request via HTTP and get the response back and display it. Repeat as desired. – Twisty Jul 26 '19 at 21:12
  • Im not very familiar with marquee (or much terminology in particular) but if that means to have the string scrolling one the LCD then no just a static display that will update at set intervals – BlazeDakota Jul 26 '19 at 21:13
  • Yes thats exactly what im trying to do. I will try the API Call – BlazeDakota Jul 26 '19 at 21:20

1 Answers1

0

I guess most folk will suggest you use sockets to transmit the data, but personally, I would start a little Redis instance on the Pi connected to the ADC.

Redis is an "in-memory, data structure server". It can store and share integers, strings, hashes, sets, queues and lists between any number of processes on any number of machines. It is seriously fast too.

So your Pi with the ADC just stuffs the latest value in a Redis string whenever it reads a new value. In bash, that would be:

redis-cli "set ADCreading 897"

The other Pi, with the remote display, just gives the IP address of the ADC Pi and grabs the latest value if it wants it. The two are nicely decoupled. In bash that would be:

redis-cli -h <IPADDRESS_OF_ADC_RASPI> "get ADCreading"

You can put values into Redis and read them out with bash, Python, PHP, C, C++...

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Would the server constantly have to update that value? An API or Socket call could trigger a read of the sensor data at that time and give an up to the moment reading. With Redis, you'd have to run an update every second or possible have old data when the call comes in. – Twisty Jul 26 '19 at 21:30
  • The question didn't mention any timing constraints, but if you update the reading 10 times per second in Redis, your client will not getting a reading older than 1/10th second. – Mark Setchell Jul 26 '19 at 21:34
  • Good to know! Does it cause much of a load on CPU/Memory? – Twisty Jul 26 '19 at 21:51
  • No, it's brilliant. Try it. It's free. Python interface is simple too. – Mark Setchell Jul 26 '19 at 21:54
  • I am going to totally check it out, I could see lots of good uses for this. – Twisty Jul 26 '19 at 22:05
  • does using this method require both the devices to be connected to the same wifi network and be discover able to each other? could it be done over bluetooth? (I ask because at the moment i am not able to connect both to a wireless network) – BlazeDakota Jul 27 '19 at 06:17