Go to advanced search

by richiepp
Sat Sep 24, 2016 1:06 pm
Forum: Other programming languages
Topic: Node.js Thermostat
Replies: 2
Views: 1316

Re: Node.js Thermostat

I poked around here but didn't see anything that looked like it would work.
https://www.npmjs.com/search?q=thermostat&page=1
by richiepp
Mon Sep 12, 2016 5:40 pm
Forum: Other programming languages
Topic: Node.js Thermostat
Replies: 2
Views: 1316

Node.js Thermostat

Hey All, Thanks to Heater for working with me to use Node.js to render serial data from temp sensors hooked up to an Arduino. https://www.raspberrypi.org/forums/viewtopic.php?f=34&t=151184&p=1004116&hilit=richiepp#p1004116 Now that I have the temp sensors sending serial data from the Arduino to the ...
by richiepp
Sat Jul 02, 2016 6:59 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

Let me say more about my project. So this is a "home automation" project that will include a variety of sensors and switches. Each room in the house will have it's own web page that will render temperature and any other sensor data from that room. It'll also include a keypad to toggle lights and ren...
by richiepp
Sat Jul 02, 2016 5:22 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

Awesome it works in Safari now! Now that the data is flowing I can start playing with the layout and user interface. After trying to tweak the app.js aka the React script I'm finding it's a little more involved than just tweaking the html. I'll be reading up on react.js in the coming days. I'd like ...
by richiepp
Fri Jul 01, 2016 3:30 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

It Works!!!! Thanks so much Heater! Well, it mostly works.... When I pull it up in Safari on my iphone and ipad the page renders but the data does not. I get a status message that says "Fetching Data" and that's it. I tried it on a couple different ports; 8080 and 8888 and get the same result. I eve...
by richiepp
Sun Jun 26, 2016 2:19 pm
Forum: Other programming languages
Topic: Light switching @ Sunrise and Sunset
Replies: 8
Views: 4429

Re: Light switching @ Sunrise and Sunset

I continued building this out and it came to three files and a couple of cron jobs. Each day at 2a.m. I run the following php from a cron job. <?php $myfile = fopen("/usr/lib/cgi-bin/timers/srss_today.txt", "w") or die("Unable to open file!"); $txt = date_sunrise(time(), SUNFUNCS_RET_STRING, 42.3536...
by richiepp
Sun Jun 26, 2016 12:10 am
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

OK, I'm a few steps closer. My server and serialport script currently looks like the following. This works when I go to http://localhost:8080/temp and it renders the serial port data. var express = require('express'); var app = express(); var temperature; app.use(express.static('public')); app.liste...
by richiepp
Mon Jun 13, 2016 8:29 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

Another baby step. I've got the server set up and it renders the temperature and timestamp as expected. However the data it renders is static. I have to refresh the page to see an updated reading. var express = require('express'); var app = express(); app.get('/', function (req, res) { res.send('Hel...
by richiepp
Mon Jun 13, 2016 4:53 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

ok, here's what might be a dumb question, a fundamental Node.js question I guess. Where do I put the fetch code? Do I create a directory structure like this http://localhost/api/temperature and create and index.html file in the temperature directory. Or are all Node.js pages created on the fly with ...
by richiepp
Mon Jun 13, 2016 4:36 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

Baby steps. Ok, I've tried adding my serialport code to your server example and can get it working halfway. The way it's written now it shows the timestamp but not the contents of the serial stream 'use strict'; var serialport = require('serialport'); var SerialPort = serialport.SerialPort; var pars...
by richiepp
Mon Jun 13, 2016 2:04 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Re: Node.js, serialport, AJAX - Temp Sensor

Wow thanks for such a detailed response Heater! I started working through your notes and got the server up and running....easy enough. But I'm getting stuck at the second step. So here is the server code with the temperature function, note it doesn't work because "temp" is not defined. var express =...
by richiepp
Sat Jun 11, 2016 2:07 pm
Forum: Other programming languages
Topic: Light switching @ Sunrise and Sunset
Replies: 8
Views: 4429

Light switching @ Sunrise and Sunset

I'm developing an outdoor lighting system that turns lights on at sunset and truns them off at dawn. PHP has a function that returns the time for sunrise and sunset based on the coordinates you set. So I'm running a cron job at 2am daily to write to a file with that days times. So my log file for to...
by richiepp
Sat Jun 11, 2016 1:41 pm
Forum: Other programming languages
Topic: Node.js, serialport, AJAX - Temp Sensor
Replies: 23
Views: 10580

Node.js, serialport, AJAX - Temp Sensor

Hey All, I've started to play around with Node.js and the serialport module to communicate with an Arduino. I've got a temperature sensor on the Arduino that reads and sends a serial signal every second. I'm catching that signal and writing to a text file. I read that text file every second and retu...
by richiepp
Thu Jun 09, 2016 5:37 pm
Forum: Other programming languages
Topic: Struggling to get a node.js script running with forever at r
Replies: 1
Views: 1705

Struggling to get a node.js script running with forever at r

Hey All, I'm trying to fire a node script with forever @reboot and I'm having a hard time. Here's what I've tried. Note my script does in fact work and can be called with the following forever start /var/www/html/node_stuff/app.js but when I put it in the crontab it doesn't seem to fire @reboot fore...
by richiepp
Mon Jun 06, 2016 11:39 am
Forum: Other programming languages
Topic: Node.js to display serialport data on webpage
Replies: 1
Views: 1088

Node.js to display serialport data on webpage

I have an Arduino with a temperature sensor hooked up that sends serial messages with the current reading every few seconds. I want to use Node.js to read those serial signals and render them in real time to a webpage. I have a simple node script that reads the serial port. and returns what it sees....
by richiepp
Sat Jun 04, 2016 6:28 pm
Forum: Python
Topic: Listen for serial signals from Arduino
Replies: 3
Views: 1804

Re: Listen for serial signals from Arduino

I was able to get around the reset issue by using Serial1 on the Mega. I'm able to open and close it without resetting ;)

I'll check out Johnny Five
Thanks
Rich
by richiepp
Sat Jun 04, 2016 4:43 pm
Forum: Python
Topic: Listen for serial signals from Arduino
Replies: 3
Views: 1804

Listen for serial signals from Arduino

Hey All, I'm working on a home automation project that uses a RPI3 and an Arduino Mega. Most of the pins on the Pi will be used up by a TFT touchscreen monitor. So I'm trying to do all of the IO through the Arduino and communicate back and forth over serial with the Pi. I have an IR receiver that in...
by richiepp
Fri Jun 03, 2016 3:20 pm
Forum: Other programming languages
Topic: AJAX Button change css class
Replies: 0
Views: 738

AJAX Button change css class

Hey All, I've got an AJAX button that calls a python script that toggles a pin on an Arduino Mega. The script reads and writes a 1 or 0 to a text file called led_status. If the script reads 1 it changes it to 0 and turns the pin low and vice versa. My task at hand is to change the css of the button ...
by richiepp
Fri Jun 03, 2016 2:12 pm
Forum: Python
Topic: read and or write to a txt file with python
Replies: 5
Views: 3345

Re: read and or write to a txt file with python

Thanks PCManBob, that did it! But I did need to add the port.write() lines to make it toggle the pin. The completed code is below. On to my next question. I'm going to be sending signals like this to 15 or more pins on an Arduino Mega. I'll be using AJAX calls to trigger the scripts. Should I create...
by richiepp
Fri Jun 03, 2016 10:08 am
Forum: Python
Topic: read and or write to a txt file with python
Replies: 5
Views: 3345

Re: read and or write to a txt file with python

Thanks for the tutorials. So to pull this off I'll need an if else statement. I've tried that below but I can't seem to get it to work properly. !/usr/bin/python import serial import cgitb cgitb.enable() port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=3.0) current_status = open('led_stat...
by richiepp
Thu Jun 02, 2016 10:07 pm
Forum: Python
Topic: read and or write to a txt file with python
Replies: 5
Views: 3345

read and or write to a txt file with python

Hi, I have two simple python scripts to send serial signals to an Arduino to toggle pins high (H) and low (L). I'm writing to a text file the status of the pin H or L. I want to combine the two scripts to read the text tile first and then toggle the pin to the opposite state. Below is my code to tur...
by richiepp
Thu Jun 02, 2016 3:51 pm
Forum: Python
Topic: Arduino RPI Serial Python turns the pin low after executing
Replies: 3
Views: 970

Re: Arduino RPI Serial Python turns the pin low after execut

Update I was able to get around this by using the Serial1 port on the Mega; no more resetting. I'm using this FTDI cable to make the connection https://www.sparkfun.com/products/9717 Here's what the Arduino sketch looks like. const int ledPin = 12; // the pin that the LED is attached to int incoming...
by richiepp
Thu Jun 02, 2016 2:58 pm
Forum: General programming discussion
Topic: Websocket to display temperature readings from Arduino
Replies: 1
Views: 1322

Websocket to display temperature readings from Arduino

Hey All, I'm working on a home automation project where my RPI 3 is the brains and an Arduino Mega is the brawn. I'm communicating between them via serial. I have temperature sensors on the Arduino and would like to display the readings dynamically via a webpage. What's the best way to do this? I've...
by richiepp
Tue May 24, 2016 3:06 pm
Forum: Other programming languages
Topic: Call a python script from a javascript button
Replies: 10
Views: 10232

Re: Call a python script from a javascript button

Thanks for your example Heater, it's definitely along the lines of what I'm working towards. I appreciate the well formatted code. Hats off for styling the buttons with CSS. Nice work! That being said I'm getting a 404 error on line 1456 of socket.io.js that line looks like this xhr.send(this.data);...
by richiepp
Mon May 23, 2016 4:14 pm
Forum: Other programming languages
Topic: Call a python script from a javascript button
Replies: 10
Views: 10232

Re: Call a python script from a javascript button

Thanks Heater I'll check it out! I guess this brings me to the broader question of what kind of web server should I be running? Like a lot of us I have years of experience with Apache LAMP servers. Do I set that aside and learn node.js? Or perhaps run a hybrid server using them both? I just found th...

Go to advanced search