Access Raspberry Pi to read data.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 312
Joined: Tue Apr 10, 2012 9:18 am

Re: Access Raspberry Pi to read data.

Post by ghettocottage » Sun May 05, 2019 5:08 am

Just a thought:
It would not be too complicated to create (with some help) a bash script that runs on your pi that would ssh into your webserver and write all the data to a file there.

Your webserver could then do the rest with that file.

The script on the pi could run on a schedule of however frequently you wanted it to, but creating a cron-job.

That might simplify things a bit. and you would not have to mess with the pi much once the script was working.

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sat Apr 02, 2011 4:06 pm

Re: Access Raspberry Pi to read data.

Post by revRider » Tue May 07, 2019 2:00 pm

Yes.. That is possible..

My main goal was to do most of the heavy lifting using LiveCode.

Since I can't program using LiveCode on the Pi, I figured using a desktop, to do a reach around to gather the data , parse then pass to server, might be possible.

Otherwise I could do everything with the pi using python and php. But the end result wouldn't be as pretty, or as easy to share with the community.

~David

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6861
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Access Raspberry Pi to read data.

Post by FourthWorld » Tue May 07, 2019 2:16 pm

You could conceivably use LC 7.0.4 for the Pi deployment.

But as for your original strategy, it sounds like you have everything you need except login. Setting up a shared key, putting the public key on the Pi, should accomplish what you need.

https://www.digitalocean.com/community/ ... sh-keys--2

With that, you could login, and call whatever's need to obtain the data, from LC's shell function.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sat Apr 02, 2011 4:06 pm

Re: Access Raspberry Pi to read data.

Post by revRider » Wed Jun 12, 2019 10:43 pm

Would love to deploy/run LiveCode on a Raspberry Pi, it is one of the features I've supported and paid/donated for for years. Think the Pi would be a great tool for low cost, remote (disposable) computers. Now with wifi, they are easy to deploy in the field and communicate with. However getting data too and from the Pi reliably has been an issue. - All as a teaching tool.

Know I was able to get LiveCode/RunRev on a Pi years ago, think in version 3 or 6. But files couldn't be compiled.

Tried version 7.0.4, no RPI version. Got excited there for a minute.

Just trying to get the data collected from the Pi, to either another computer or Server, without having to jump through a lot of unnecessary security hoops. Just saying. It is so easy to reimagine a pi, and you really have to when the computers can be broken (child handled to death). -- If the program could be compile using LiveCode on a raspberry Pi, it could be started on reboot and start sending data to a database (server). yes I know data could be collected on pi. But the Pis tend to die/crash/SIM Death..

We have data being collecting from weather sensors that needs to be distributed, or sent elsewhere for the students to access. (ROFL) Don't think it would be a good idea to let students access 1 pi all at once, while it is collecting data.

Tried the key sharing, ended up hosing a couple of pis and wasting lots of time. Was never able to do anything constructive going that direction. Again, just saying.

Know everyone is trying to help. Thank You.

Guess I need to parse the data and send to LiveData, then figure out how to use LiveData to release the data to students. (IF I can do that from a Raspberry Pi). Sounds fun. (gag) LOL -- Again the data is on a pi with an Arduino, with weather shield, plus AcuRite weather stations sending data to a pi collecting data off 433 mhz sensors.. So in total 3 weather stations, 2 Pis. (but think once I figure out data collections the number of Pis isn't important).

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 312
Joined: Tue Apr 10, 2012 9:18 am

Re: Access Raspberry Pi to read data.

Post by ghettocottage » Wed Jun 12, 2019 11:21 pm

I have a project I am working on that involves an OrangePi set up out in a field (literally out in a field) and I use one of these things: https://hologram.io/nova/ plugged into the Pi to send small chunks of data to a server where I have Livecode Server running...which collects that data and does a few things with it.

So far so good. I am having to re-do my first attempt because of some voltage issues with my electrical wiring, but other than that everything is working. In fact, I purchased a RaspberryPi Zero to replace the OrangePi, since I did not need a big ethernet port jutting out.

I am fairly confident that I could do a weather-station using the exact same setup I have now.

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sat Apr 02, 2011 4:06 pm

Re: Access Raspberry Pi to read data.

Post by revRider » Thu Jun 13, 2019 3:26 pm

That would be cool. But since I'm only a computer teacher, and most of the funds come out of my pocket, the Cellular solution is out of my budget (could end up needed two as well)... I have been thinking about trying 433mhz, very cheap add-on boards.

Using 433mhz and sending the data serially, I could send data to almost anything, including a computer that supports LiveCode. At the moment that is the direction I am trying. Unsure if my skill set will pull us through but I'm going to try.

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 312
Joined: Tue Apr 10, 2012 9:18 am

Re: Access Raspberry Pi to read data.

Post by ghettocottage » Thu Jun 13, 2019 4:02 pm

In my original setup, I had an old Linksys WRT54g router with a couple of large antennas. You can find those routers at thrift-stores for a few dollars and install dd-wrt on them. The antennas un-screw and can be replaced with larger, more powerful antennas. That router can be ran on 12v (solar panels or auto battery) and is very forgiving of any voltage surges (probably the reason they were notorious for being such tough routers)

I was able to have that setup out roughly 100 yards from a house that had wifi. I think my only expense was the antennas from eBay.

The only reason I had to switch to the nova modem was I needed a lot more distance away from any internet source.

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 46
Joined: Sat Apr 02, 2011 4:06 pm

Re: Access Raspberry Pi to read data.

Post by revRider » Sat Jun 29, 2019 7:53 pm

Ok.. Gave up on using a Raspberry Pi! But did get the rtf_433 working on a Mac with it own receiver.

Been trying for two days to get rtl_433 to send data to my app using Shell.. I tested in terminal it works fine.

I assume it is because it is streaming data, and isn't stopping.

Code: Select all

   
   put empty into fld "fldmonitor"
   put empty into fld "myCount"
   put empty into fld "fldData"
   local myVar
   
   set the shellCommand to "/usr/local/bin"
   put "rtl_433 -M utc -F json -G " into tCommand
   put shell(tCommand) into myVar
   put the number of lines in myVar into fld "myCount"
   put the result after fld "fldmonitor"
   
   wait 3 seconds
   put "rtl_433 -M utc -F json -G" into tCommand
   wait 3 seconds
   put tCommand after fld "fldData"
   get shell (tCommand) 
   put the result after fld "fldmonitor"
   
Don't get why this is so difficult. I've been able to write network scanners with data parsing with no problem. This is a real ego killer in LiveCode.

Below is what is return from terminal:
rtl_433 version 18.12-214-gf199d35 branch master at 201906232139 inputs file rtl_tcp RTL-SDR
Trying conf file at "rtl_433.conf"...
Trying conf file at "/Users/david/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...

Use -G for testing only. Enable protocols with -R if you really need them.


Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 121 out of 127 device decoding protocols [ 1-4 6-8 10-17 19-26 29-64 67-127 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
{"time" : "2019-06-29 18:52:33", "model" : "Acurite tower sensor", "id" : 2766, "sensor_id" : 2766, "channel" : "A", "temperature_C" : 22.700, "humidity" : 47, "battery_low" : 0}
{"time" : "2019-06-29 18:52:33", "model" : "Acurite tower sensor", "id" : 2766, "sensor_id" : 2766, "channel" : "A", "temperature_C" : 22.700, "humidity" : 47, "battery_low" : 0}
{"time" : "2019-06-29 18:52:33", "model" : "Acurite tower sensor", "id" : 2766, "sensor_id" : 2766, "channel" : "A", "temperature_C" : 22.700, "humidity" : 47, "battery_low" : 0}
^Z

ghettocottage
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 312
Joined: Tue Apr 10, 2012 9:18 am

Re: Access Raspberry Pi to read data.

Post by ghettocottage » Sat Jun 29, 2019 9:05 pm

you could just write a bash script and then call it from Livecode like:

Code: Select all

   put shell("./functions/yourscript) into tScript
if you have variables you need to pass, you just send them to your bash script:

Code: Select all

   put shell("./scripts/yourscript var1 var2") into tScript
and then your bash script can read those:

Code: Select all

#!/bin/bash
#Options ###
VAR1=$1
VAR2=$2

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”