I'm going for a similar next step.
The cars must be parked in a very specific position relative to the side wall and the garage door, or otherwise it's almost impossible to move around the garage.
Something like this Hek project.
Cheers
I'm going for a similar next step.
The cars must be parked in a very specific position relative to the side wall and the garage door, or otherwise it's almost impossible to move around the garage.
Something like this Hek project.
Cheers
Hi @Grubstake,
Not much else...
You can have node running (as a service or daemon) on any device that has a USB port (PC, mac, RPI) and it is agnostic of what controller you have.
Are you interested in the code details? Check the MySensors post I included in the link.
The MySensors typical messages is something like this 30;5;1;0;37;70
Which gets translated to /whateverpathyouwant/out/30/5/1/0/37 Payload: 70
And vice versa.
The reason I did this was because I had no WiFi or Network enabled gateway.
Cheers
Hi @Grubstake
In my case, I just use a nodeJS script which reads from serial and publishes to mqtt. It also subscribes from mqtt and sends it to serial.
Pretty straight forward. For more details, look here.
Cheers
Hi @Samuel235 ,
And it works fine, whatever the calibration error is, it's consistent.
The base
The cover
So in reality, the finished part size might not be exactly that, but whatever the difference is, it is propagated to both parts. This probably wouldn't be true if I printed the parts separately in different printers.
Anyway, we're talking about tenths of millimeters.
3D printer generically are very precise.
Cheers
Hi @Samuel235 ,
It just snaps in. The lid sits on the first lip of the base. It's actually quite tight.
@dbemowsk , the problem is that I lost my screws... (portuguese joke meaning lost my marbles or gone crazy)
Anyway, do you create the threads for the screws in the plastic? or do you use self-threading...
When I do my supports I make them snap-on, like a little wider in the base and then a bit of plastic that goes through the board holes. If the holes are too thin the snap-on bit breaks.
cheers
@sundberg84 , absolutely, please do!
Cheers
@dbemowsk, I'm very interested in your decora style wall plate, maybe we can compare notes
I'm not sure this is the best place to put this but here goes.
Here are some files to create a 3D printed box or bumper for the popular Easy PCV by @sundberg84
The STL file
0_1490735357002_EasyBoard_Base.stl
the SketchUp
0_1490735391058_GarageDoorMonitor.zip
Have fun
Yeah, I wanted to know the exact position of the door, if it was opening or closing etc.
Anyway I'll gladly share the 3D files for the Easy board
This is the SketchUp file with the base, rail, lid and enclosure for the sonic.
0_1490732828480_GarageDoorMonitor.zip
And this one the base and lid for the monitor.
The Easy boards I have are v8 and the mounting holes are so small that I couldn't create a support that wouldn't break, so I decided to make some rail/slide system.
Also because I don't solder the Arduino or radio directly to the board, the lid becomes very tall. But its easy to adjust in the 3D files.
If you prefer STL files, I'll upload them
Cheers
Hi Folks
After leaving my garage door open all night for several times, I had to go ahead and make a MySensors contraptions for it.
The garage door system I have has 1 single button it will either open or close the door depending on position, the safety beams and the last operations.
Since I know nothing about electronics, hacking the motor electronics was beyond my skill set, so I decide to sensorize the button operations. In order to figure out if the door was opening or closing I used a sonic distance relative to de door rail. I was expecting to have issues with precision but I was rather surprised it worked so well.
The base is the fantastic Easy/Newbie PCB for MySensors by @sundberg84 with a bumper/box of my own creation.
Coupled with some extra pieces as the rail support, the insert for the sonic sensor and the box lid it self.
On the controller it looks like this
With door Open
With door Closed
On the other side, I've created a simple led sensor which receives a door open/closed signal directly from the garage sensor to turn on or off a led.
As always feedback is appreciated
Cheers
I'm interested in organizing a workshop
@Jason-Brunk
Lets not highjack this thread, I'll ping you via PM
@Jason-Brunk
Where are you stationed? I'm in Atlanta, Georgia. Maker faire Atlanta is coming soon...
What a great initiative!
If the video cant be recorded or shared I wonder if you would share some of the organizational details so it would make it easier to replicate this in other parts of the world.
Cheers
This is great.
I just got myself one of these Dioders
Could you detail the connections between arduino and the ikea board?
For example when you label AIN6 on the ikea board picture it connects to D6 in arduino?
Is this correct?
Can we filter by the ones that are kit's, assembled, PCB?
I dont know where you got the idea but is very accurate so to speak.
You can actually find a Weather Galo de Barcelos, its has some paint that changes color based on humidity.
Cool idea, cheers
A Barcelos rooster, fantastic!
You from PT @AWI ?
You're right it should be MOTION_A_TRIGGER_PIN. And it should be -1 not -2 confirm?
In this line
#define INTERRUPT DIGITAL_INPUT_SENSOR-2
DIGITAL_INPUT_SENSOR does not exist, Im assuming its the pin from the PIR so replace it with
#define INTERRUPT MOTION_A_CHILD_ID-2
Also you have an extra } in your code
if (SONAR_B_dist != SONAR_B_lastDist) {
send(SONAR_B_msg.set(SONAR_B_dist));
SONAR_B_lastDist = SONAR_B_dist;
}
sleep(SLEEP_TIME);
}
}
//else{
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(INTERRUPT,CHANGE, MOTION_SLEEP_TIME);
//}
}
Replace with
if (SONAR_B_dist != SONAR_B_lastDist) {
send(SONAR_B_msg.set(SONAR_B_dist));
SONAR_B_lastDist = SONAR_B_dist;
}
sleep(SLEEP_TIME);
}
//else{
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(INTERRUPT, CHANGE, MOTION_SLEEP_TIME);
//}
}
Cheers
The "trick" is this line
// Sleep until interrupt comes in on motion sensor. Send update every two minute.
sleep(INTERRUPT,CHANGE, SLEEP_TIME);
You can use something like this
int8_t sleep(uint8_t interrupt1, uint8_t mode1, uint8_t interrupt2, uint8_t mode2, unsigned long ms=0);
Take a look in the MySensors API page under "sleeping" http://www.mysensors.org/download/sensor_api_15
Cheers
It should be something like this
Define new child id and pins for the new sensor
#define SONAR_A_CHILD_ID 1
#define SONAR_B_CHILD_ID 2
#define SONAR_A_TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define SONAR_A_ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define SONAR_B_TRIGGER_PIN 8 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define SONAR_B_ECHO_PIN 7 // Arduino pin tied to echo pin on the ultrasonic sensor.
Then instantiate 2 sonars
NewPing sonar_A(SONAR_A_TRIGGER_PIN, SONAR_A_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar_B(SONAR_B_TRIGGER_PIN, SONAR_B_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
Now instantiate 2 messages and 2 lastDistance variables
MyMessage SONAR_A_msg(SONAR_A_CHILD_ID, V_DISTANCE);
int SONAR_A_lastDist;
MyMessage SONAR_B_msg(SONAR_B_CHILD_ID, V_DISTANCE);
int SONAR_B_lastDist;
Presenting the sensors
// Register all sensors to gw (they will be created as child devices)
present(SONAR_A_CHILD_ID, S_DISTANCE);
present(SONAR_B_CHILD_ID, S_DISTANCE);
Finally the loop section
void loop()
{
int SONAR_A_dist = metric?sonar_A.ping_cm():sonar_A.ping_in();
Serial.print("Ping Sonar A: ");
Serial.print(SONAR_A_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(metric?" cm":" in");
if (SONAR_A_dist != SONAR_A_lastDist) {
send(SONAR_A_msg.set(SONAR_A_dist));
SONAR_A_lastDist = SONAR_A_dist;
}
int SONAR_B_dist = metric?sonar_B.ping_cm():sonar_B.ping_in();
Serial.print("Ping Sonar B: ");
Serial.print(SONAR_B_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(metric?" cm":" in");
if (SONAR_B_dist != SONAR_B_lastDist) {
send(SONAR_B_msg.set(SONAR_B_dist));
SONAR_B_lastDist = SONAR_B_dist;
}
sleep(SLEEP_TIME);
}
Other considerations:
I did not test this but it did compile
// Enable debug prints
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
#include <SPI.h>
#include <MySensor.h>
#include <NewPing.h>
#define SONAR_A_CHILD_ID 1
#define SONAR_B_CHILD_ID 2
#define SONAR_A_TRIGGER_PIN 6 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define SONAR_A_ECHO_PIN 5 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define SONAR_B_TRIGGER_PIN 8 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define SONAR_B_ECHO_PIN 7 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 300 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
unsigned long SLEEP_TIME = 5000; // Sleep time between reads (in milliseconds)
NewPing sonar_A(SONAR_A_TRIGGER_PIN, SONAR_A_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
NewPing sonar_B(SONAR_B_TRIGGER_PIN, SONAR_B_ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
MyMessage SONAR_A_msg(SONAR_A_CHILD_ID, V_DISTANCE);
int SONAR_A_lastDist;
MyMessage SONAR_B_msg(SONAR_B_CHILD_ID, V_DISTANCE);
int SONAR_B_lastDist;
boolean metric = true;
void setup()
{
metric = getConfig().isMetric;
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Distance Sensor", "1.0");
// Register all sensors to gw (they will be created as child devices)
present(SONAR_A_CHILD_ID, S_DISTANCE);
present(SONAR_B_CHILD_ID, S_DISTANCE);
}
void loop()
{
int SONAR_A_dist = metric?sonar_A.ping_cm():sonar_A.ping_in();
Serial.print("Ping Sonar A: ");
Serial.print(SONAR_A_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(metric?" cm":" in");
if (SONAR_A_dist != SONAR_A_lastDist) {
send(SONAR_A_msg.set(SONAR_A_dist));
SONAR_A_lastDist = SONAR_A_dist;
}
wait(1000);
int SONAR_B_dist = metric?sonar_B.ping_cm():sonar_B.ping_in();
Serial.print("Ping Sonar B: ");
Serial.print(SONAR_B_dist); // Convert ping time to distance in cm and print result (0 = outside set distance range)
Serial.println(metric?" cm":" in");
if (SONAR_B_dist != SONAR_B_lastDist) {
send(SONAR_B_msg.set(SONAR_B_dist));
SONAR_B_lastDist = SONAR_B_dist;
}
sleep(SLEEP_TIME);
}
Not sure about the radios issue.
However in your test I noticed the initialization of the eeprom to 0
The eeprom clear example in the mysendor writes 255 in all positions and I think it is influencing your test.
void setup()
{
Serial.begin(MY_BAUD_RATE);
Serial.println("Started clearing. Please wait...");
for (int i=0;i<EEPROM_LOCAL_CONFIG_ADDRESS;i++) {
hwWriteConfig(i,0xFF);
}
Serial.println("Clearing done. You're ready to go!");
}
Try it with the clear eeprom sketch and see it if works.
Also if you want to use a static id why not just use
// Define Node ID
#define MY_NODE_ID 16
Cheers
yes, indeed
source: https://www.arduino-board.com/boards/arduino-pro-mini
anyway, no worries, I was just curious
Cheers
Great Idea!
Its a good way to show our appreciation for their great work.
Cheers
@nunver your're right I need a more elegant solution for that wire, there was no particular reason to connect it on the other side.
For the protection i'm thinking a daughter board with the diode and the 9v connector and then join it with angle connectors on the main.
Cheers
@nunver, it's not my board, @sundberg84 design it and made it available for all of us.
The wire you see is to connect the RAW input to the voltage divider so I can measure the 9v battery.
Cheers
I've been using beta and i'm very happy with it.
If you do find problems, first update it again to get the newest builds and if the issue is still there report it.
I'm sure folks will appreciate having another person testing.
Cheers
@sundberg84 , I forgot to mention something.
I get my pro mini's from the local mega store and they have their own brand at a very good price.
In the model they sell the A6, A7 and Ground do not line up with the board.
Not a problem for my applications (I'm thinking of soldering some angled connectors) but I was wondering if they are supposed to be in that position from the original specs.
If you ever think of making the board a bit bigger, having 4 extra connectors for A6, A7, D8 (and an extra ground perhaps) would be nice.
Great job on these!!!
Cheers
Hi folks,
I finally had some time to assemble a couple of boards and they work perfectly.
2 things I need to do though and I appreciate any feed back folks may have.
Connect the voltage divider in a more elegant way, perhaps directly from the raw, however I wanted to keep the options open just in case some of the boards end up using REG or BAT.
Find a way to protect the VIN input against accidental reverse polarity. I ended up frying the voltage regulator on the arduino when I accidental touched the 9v battery on its connector reversed. Its quite a show with glowing red and sparks flying (the arduino actually survived but no more raw power).
@sundberg84 once again thanks for this board!!!
Cheers
Default libraries included in the IDE
User libraries
Its not uncommon to have compile issues when:
The IDE is not restarted after uncompressing/copy file to the libraries
When upgrading MySensors without deleting the old version first
I have Arduino IDE 1.6.4
Cheers
I guess reality is stranger than fiction.
To eliminate any bad connections I started by this:
void setup()
{
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
}
void loop()
{
for( int i=3;i<=6;i++){
digitalWrite(i,HIGH);
delay(500);
}
for( int i=3;i<=6;i++){
digitalWrite(i,LOW);
delay(500);
}
}
Using a 4 relay board, connected pins 3 through 6, I get a nice effect of all pins light up in sequence and then turn off in sequence.
With the relay sketch from the examples (lib 2.0.0) and debugging the load state values which where set to 0 for each sensor I have for each relay (off, ON, ON, ON).
Then on the setup I decide to reduce it to this:
void setup()
{
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
digitalWrite(pin,LOW);
Serial.print("Pin ");
Serial.print(pin);
Serial.println(" to LOW");
}
}
Same result or each relay (off, ON, ON, ON).
Starting repeater (RNNRA-, 2.0.0-beta)
Radio init successful.
Pin 3 to LOW
Pin 4 to LOW
Pin 5 to LOW
Pin 6 to LOW
send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=ok:2.0.0-beta
send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-15 s=255,c=3,t=6,pt=0,l=1,sg=0:M
send: 15-15-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
send: 15-15-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
send: 15-15-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
Presenting sensor:1
send: 15-15-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,st=ok:
Presenting sensor:2
send: 15-15-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,st=ok:
Presenting sensor:3
send: 15-15-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,st=ok:
Presenting sensor:4
Init complete, id=15, parent=0, distance=1
So I decided to re-initialize the pins once more in the loop section:
void loop()
{
if (isFirstTime){
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++,pin++) {
currState = loadState(sensor);
pinMode(pin, OUTPUT);
digitalWrite(pin,LOW);
Serial.print("Current Status sensor:");
Serial.print(sensor);
Serial.print("\t");
Serial.print("State:");
Serial.print(currState);
Serial.print("\t");
Serial.print("Pin:");
Serial.println(pin);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, currState?RELAY_ON:RELAY_OFF);
wait(500);
}
isFirstTime = false;
}
}
Now I have all relays off:
Init complete, id=15, parent=0, distance=1
Current Status sensor:1 State:0 Pin:3
Current Status sensor:2 State:0 Pin:4
Current Status sensor:3 State:0 Pin:5
Current Status sensor:4 State:0 Pin:6
Now sending some messages:
Relay 1
Current Status sensor:4 State:0 Pin:6
read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:1 On pin:3, New status: 1
read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:1 On pin:3, New status: 0
Works fine but guess what, Relay 4 also turned ON after Relay 1
Relay 2:
read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:2 On pin:4, New status: 1
read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:2 On pin:4, New status: 0
Works fine but Relay 4 blinks and stays on
Relay 3:
read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:3 On pin:5, New status: 1
read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:3 On pin:5, New status: 0
Works fine but Relay 4 blinks and stays on
Relay 4:
read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:4 On pin:6, New status: 1
read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:4 On pin:6, New status: 0
Relay 4 blinks and stays on
These relays are solid state 5v, arduino pro mini 5v and I both used the power from computer USB and a 6000 mAh phone battery with the same results.
Here is the full code:
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.0 - Henrik Ekblad
*
* DESCRIPTION
* Example sketch showing how to control physical relays.
* This example will remember relay state after power failure.
* http://www.mysensors.org/build/relay
*/
// Define Node ID
#define MY_NODE_ID 15
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
#include <SPI.h>
#include <MySensor.h>
#define RELAY_1 3 // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
#define NUMBER_OF_RELAYS 4 // Total number of attached relays
#define RELAY_ON HIGH // GPIO value to write to turn on attached relay
#define RELAY_OFF LOW // GPIO value to write to turn off attached relay
bool isFirstTime = true;
bool currState;
void setup()
{
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
digitalWrite(pin,LOW);
Serial.print("Pin ");
Serial.print(pin);
Serial.println(" to LOW");
}
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("Relay", "1.0");
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Register all sensors to gw (they will be created as child devices)
present(sensor, S_LIGHT);
Serial.print("Presenting sensor:");
Serial.println(sensor);
}
}
void loop()
{
if (isFirstTime){
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++,pin++) {
currState = loadState(sensor);
pinMode(pin, OUTPUT);
digitalWrite(pin,LOW);
Serial.print("Current Status sensor:");
Serial.print(sensor);
Serial.print("\t");
Serial.print("State:");
Serial.print(currState);
Serial.print("\t");
Serial.print("Pin:");
Serial.println(pin);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, currState?RELAY_ON:RELAY_OFF);
wait(500);
}
isFirstTime = false;
}
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(" On pin:");
Serial.print(message.sensor-1+RELAY_1);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
This could be some issue with the development branch of 2.0.0, its been some time since I refreshed.
So refreshing the libs I see a new before() section and an empty setup() from the RelayActuator example
void before() {
for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS;sensor++, pin++) {
// Then set relay pins in output mode
pinMode(pin, OUTPUT);
// Set relay to last known state (using eeprom storage)
digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
}
}
void setup() {
}
Now it runs fine
Starting repeater (RNNRA-, 2.0.0-beta)
Radio init successful.
send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-15 s=2Starting repeater (RNNRA-, 2.0.0-beta)
Radio init successful.
send: 15-15-0-0 s=255,c=3,t=15,pt=0,l=2,sg=0,st=ok:
send: 15-15-0-0 s=255,c=0,t=18,pt=0,l=10,sg=0,st=fail:2.0.0-beta
send: 15-15-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-15 s=255,c=3,t=6,pt=0,l=1,sg=0:M
send: 15-15-0-0 s=255,c=3,t=11,pt=0,l=5,sg=0,st=ok:Relay
send: 15-15-0-0 s=255,c=3,t=12,pt=0,l=3,sg=0,st=ok:1.0
send: 15-15-0-0 s=1,c=0,t=3,pt=0,l=0,sg=0,st=ok:
send: 15-15-0-0 s=2,c=0,t=3,pt=0,l=0,sg=0,st=ok:
send: 15-15-0-0 s=3,c=0,t=3,pt=0,l=0,sg=0,st=fail:
send: 15-15-0-0 s=4,c=0,t=3,pt=0,l=0,sg=0,st=ok:
Init complete, id=15, parent=0, distance=1
read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:1, New status: 1
read: 0-0-15 s=1,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:1, New status: 0
read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:2, New status: 1
read: 0-0-15 s=2,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:2, New status: 0
read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:3, New status: 1
read: 0-0-15 s=3,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:3, New status: 0
read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:1
Incoming change for sensor:4, New status: 1
read: 0-0-15 s=4,c=1,t=2,pt=0,l=1,sg=0:0
Incoming change for sensor:4, New status: 0
All relays behaving as expected before and after running a clearEEPROMconfig sketch.
So perhaps there is an issue with v1.5 but it seems the development branch of 2.0 is fine.
Or you can try to debug the hell out of it with plenty of Serial.prints.
Check with a simple sketch if your relays are fine.
If so check what are you getting from the loadState, make sure its boolean, initialize the pins to LOW in setup and if it doesn't work again in loop just once.
Try to have the relays always starting as off with no load or save state.
Cheers
I'm a noob at electronics and arduinos and have a wild imagination
I had a theory but was unsure, so I decided to test it first rather than cause more confusion.
I know this is a place of sharing, but more than once I caused more problems when trying to help.
I don't want to bring some stupid idea into the fold.
I'll report back.
@Samuel235 , @sundberg84 , thank you both
The boards have arrived!!! YES!!
It took about 3 weeks between the shipping status and my mailbox. I guess I cant complain.
@sundberg84 I do have another question.
Are the pins A6, A7 and the extra ground (next to A6) connected at all? is it worth to solder a connector on them to the PCB?
Edit: or maybe 2...
D8 does not seem to be used, is this correct?
Cheers
I'm just curious, maybe its the arduino IDE version or something.
I'm using 1.6.4 and I get this:
However opening with a text editor is fine:
Cheers
DC Motor, very interesting!
Do you have end stops? The sketch doesn't open for some reason...
Cheers
@derwish, I'm getting an illegal instruction error.
It seems to come from the dnx, actually when I try dnx --version I get the Illegal instruction.
the dnvm list seems fine
pi@rpic:~ $ dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 coreclr x64 linux
* 1.0.0-rc1-update1 mono linux/osx default
not sure where it went wrong and I have no clue where to look.
This is Raspien latest version after plenty of apt-get update and upgrade
EDIT:
Re installed from start, dnx is working fine and I can even start the web server.
However now I cant get passed the serial device selection
I have the arduino gateway on usb with the gateway beta 2.0 installed, and I get this:
Any tips?
Thanks
Very impressive!
That was some thinking out the box, congrats.
The signals processing idea is just genius.
Cheers
I have this one, looks the same...
I can't wait to get mine, I bet on version 8 .Fear {display:none;} despite being a noob with electronics.
Although I do have a question, for a 5v pro mini...
Suppose I power this using a 9v battery, assuming connection to the RAW, that means not BAT or REG jumpers ?
And I also wont be able to use the voltage divider to read the voltage.
However It looks like that if there is no jumper in BAT or REG the voltage divider circuit is independent. Would it be possible to re-wire the voltage divider circuit to measure the RAW 9v from the battery?
Does anyone know what happens to the internal voltage regulator when the battery gets week? Would the vcc library get any idea of what is happening to the current internally?
Cheers
Depending on what version of the library you're using it could be:
For version 1.5
void setup()
{
// Initialize library and add callback for incoming messages
gw.begin(incomingMessage, AUTO, true);
// Send the sketch version information to the gateway and Controller
gw.sendSketchInfo("Relay", "1.0");
where AUTO means auto assign, so replace by your static id
gw.begin(incomingMessage, 10 , true);
For version 1.6/2.0 beta
It would be
// Define Node ID
#define MY_NODE_ID 7
// INCLUDES //
#include <SPI.h>
#include <MySensor.h>
Cheers
Hi Folks,
Risking a bit of an off-topic, I was wondering if this community could help on this.
I was using an RPi with a serial gateway connected running mosquitto and openhab fine for more than a month.
Yesterday the raspberry stopped recognizing anything plugged in the USB ports.
Otherwise seems working fine.
I got the dreaded message "usb 1-1-port2: over-current change" with nothing connected to the USB's.
The red light is always on, the green blinks occasionally and the RPi boots normally form the SD card
I'm using a 2 amp "good"power supply.
Has anyone experienced this? Is it solvable?
Thanks
In theory you could use nodeJS to read from serial and push to MQTT.
From there you should be able to have 2 MQTT enabled controllers subscribing/publishing to broker.
That should be an interesting experiment
Cheers
Hi Folks
While adding mqtt feature to my controller and inspired by @cranky and his node-red controller, I've created a simple nodejs app to do 2 things:
Here is the app.js
// LIBS
var com = require("serialport");
var mqtt = require('mqtt');
// SERIAL PORT SETTINGS
var serial_port = '/dev/ttyACM0';
// var serial_port = 'COM3'; // windows
// MQTT SETTINGS
var mqtt_host = 'mqtts://m10.cloudmqtt.com';
var mqtt_port = 8883;
var mqtt_username = 'user name';
var mqtt_password = 'password';
var KEY = 'yourkey';
// publications will be made into /haall/yourkey/out/x/x/x/x
// subcriptions will come from /haall/yourkey/in/x/x/x/
// adjust as necessary
// MQTT CLIENT OPTIONS
var mqtt_Options = {
port: mqtt_port
,keepalive: 10 //seconds, set to 0 to disable
,clientId: 'haall_' + KEY
,protocolId: 'MQTT'
//,protocolVersion: 4
,clean: false //set to false to receive QoS 1 and 2 messages while offline
,reconnectPeriod: 1000 // milliseconds, interval between two reconnections
,connectTimeout: 30 * 1000 //milliseconds, time to wait before a CONNACK is received
,username: mqtt_username //the username required by your broker, if any
,password: mqtt_password //the password required by your broker, if any
/*
,incomingStore: , // a Store for the incoming packets
,outgoingStore: , // a Store for the outgoing packets
*/
//a message that will sent by the broker automatically when the client disconnect badly. The format is:
,will: {topic: '/haall/'+KEY+'/out', // the topic to publish
payload:'Client haall_' + KEY +'has lost connection', // the message to publish
qos: 1, // the QoS
retain: false // the retain flag
}
}
// SERIAL PORT
var serialPort = new com.SerialPort(serial_port, {
baudrate: 115200,
parser: com.parsers.readline('\n')
});
// START SERIAL PORT
console.log('Opening Serial port...');
serialPort.open(function (error) {
if ( error ) {
console.log('failed to open: '+error);
} else {
console.log('Serial port opened!');
}
});
// START MQTT
console.log('Starting MQTT...');
var mqtt_client = mqtt.connect(mqtt_host,mqtt_Options);
console.log('Subscribing MQTT...');
mqtt_client.subscribe('/haall/'+KEY+'/in/#');
console.log('Publish MQTT...');
mqtt_client.publish('/haall/'+KEY+'/out', 'HAALL mqtt client started at '+ new Date());
// SERIAL PORT OUTGOING
serialPort.on('data', function(data) {
if (data.indexOf('0;0;3;0;9;') == 0) {
console.log(' I_LOG: '+data);
mqttPublish(data);
}
else{
console.log(data);
mqttPublish(data);
}
});
// MQTT INCOMING
mqtt_client.on('message', function (topic, message) {
var m = topic.toString();
m = m.replace('/haall/'+KEY+'/in/','');
m = m.split('/').join(';');
m = m + ';' + message.toString();
serialPort.write('' + m + '\n');
console.log('INCOMING MQTT: ' + topic + ':' + message.toString());
});
// MQTT OUTGOING
function mqttPublish(data){
var topic = '/haall/'+KEY+'/out/';
var params = data.split(';');
topic = topic + params[0] + '/';
topic = topic + params[1] + '/';
topic = topic + params[2] + '/';
topic = topic + params[3] + '/';
topic = topic + params[4] + '';
var payload = params[5];
mqtt_client.publish(topic,payload);
console.log('OUTGOING MQTT: ' + topic + ' Payload: ' + payload);
}
and the package.json
{
"name": "gw",
"version": "0.0.2",
"description": "Gateway Module for MySensors",
"dependencies": {
"serialport": "^1.4.5",
"mqtt": "^1.7.0"
},
"main": "gw.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Cheers
Ok, lets see if I can replicate your situation
Would you post the sketch and the log form serial?
Something like this
Serial.print("Initializing DHT... ");
DHT _dht;
_dht.setup(DHT_PIN);
delay(_dht.getMinimumSamplingPeriod());
Serial.println("Done!");
Or check the example here
Cheers
Very interesting, I'll definitely take a look.
Had similar situation when creating classes independent of my sensors, where the main sketch pools or sends information to/from them.
Cheers
Thanks for your enthusiastic support!!!
The reason for the big power supply is that I intend to have 2 solenoid valves to control the water flow, one to send water to the column the other to recirculate the water in the bucket (needed when adding nutrients or adjusting the PH). Those run on 12v and can consume some amps.
The next step would be to add a water level sensor, I'll fry the pump if the water level drops to low.
The most difficult parts to get are the PH sensor and the TPM/TDS sensor, not only expensive but most of then are not designed to be permanently submerged.
In the long run I'm also planning for 3 peristaltic pumps to send nutrients, acidic solution and base solution to adjust PH and nutrients level. These often run on 12v.
The idea of getting the electronics on the column is quite interesting. It would have to be on top since the rest of the column is not water tight. I would need to find some clever way to deal with the cables.
Any way, I've just finished adding the plants. Not the ideal time to plant anything (its winter here) but the frost is gone and they say lettuce goes well with cold temperatures.
This is what it looks like week 0. We'll see how it goes.
Cheers
I can try to give it a shot.
My objective is the MQTTGateway but with what you've done so far I think I can try to tackle it.
It would be interesting to add this to the development branch I wonder what @hek and the MySensors folks think about that possibility
Thanks
Hi Folks,
Another update on this project
I've finally finished with the software. Added a DHT22 for air temperature and humidity and also a Dallas for the water temperature.
Assembling the hardware was a bit more challenging then anticipated, but with no PCB, i've decided to use a proto shield and maintain support/flexibility for both UNO and MEGA boards. Soon after I've realized the code does not fit a UNO (too much debug eventually)
Also created a simple case to enclose it all.
The Column it self
If anyone would likr to take a look at the code, feed back is much appreciated!
Finally the dashboard looks like this
Cheers
EDIT: Forgot to add the startup log
Starting sensor (RNNNA-, 1.6.0-beta)
Radio init successful.
Initializing DHT... Done!
Dallas Temperature IC Control Library Demo
Locating devices...Found 1 devices.
Parasite power is: OFF
Device 0 Address: 2817611D070000C3
Device 0 Resolution: 9
RTC module activated
The DS1302 is write protected. This normal.
RTC Sync TieStatus: 2 timeSet 2 Ok!
send: 7-7-0-0 s=255,c=3,t=1,pt=0,l=0,sg=0,st=ok:
read: 0-0-7 s=255,c=3,t=1,pt=0,l=10,sg=0:1454110229
Time value received: 1454110229
Pump Time:2016/01/29 23:30:28
send: 7-7-0-0 s=255,c=3,t=15,pt=1,l=1,sg=0,st=ok:0
send: 7-7-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:1.6.0-beta
send: 7-7-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
read: 0-0-7 s=255,c=3,t=6,pt=0,l=1,sg=0:M
Starting presentation
send: 7-7-0-0 s=255,c=3,t=11,pt=0,l=6,sg=0,st=ok:Hydro9
send: 7-7-0-0 s=255,c=3,t=12,pt=0,l=4,sg=0,st=ok:v0.1
send: 7-7-0-0 s=1,c=0,t=3,pt=0,l=11,sg=0,st=ok:Pump Switch
send: 7-7-0-0 s=2,c=0,t=23,pt=0,l=10,sg=0,st=ok:Pump Cycle
send: 7-7-0-0 s=3,c=0,t=25,pt=0,l=9,sg=0,st=ok:Pump Mode
send: 7-7-0-0 s=4,c=0,t=23,pt=0,l=14,sg=0,st=ok:Pump Scheduler
send: 7-7-0-0 s=5,c=0,t=23,pt=0,l=13,sg=0,st=ok:Pump Daylight
send: 7-7-0-0 s=6,c=0,t=6,pt=0,l=10,sg=0,st=ok:Air Sensor
send: 7-7-0-0 s=7,c=0,t=6,pt=0,l=12,sg=0,st=ok:Water Sensor
send: 7-7-0-0 s=10,c=0,t=23,pt=0,l=9,sg=0,st=ok:Pump Time
End presentation
Init complete, id=7, parent=0, distance=1
**************** PUMP STATUS ***********************
Pump Mode is: Daylight
Pump Cycle: On:15 Off:15
Pump Schedule: Start:07:33 Stop:17:30
Pump Daylight: Start:70 Current:59
Pump Time: 2016/01/29 23:30:34
****************************************************
************* ENVIRONMENT STATUS *******************
Air temperature:10.60 Air humidity:37.90
Water temperature:10.00
****************************************************
send: 7-7-0-0 s=1,c=1,t=2,pt=1,l=1,sg=0,st=ok:0
send: 7-7-0-0 s=3,c=1,t=19,pt=2,l=2,sg=0,st=ok:3
send: 7-7-0-0 s=4,c=1,t=24,pt=0,l=5,sg=0,st=ok:07:33
send: 7-7-0-0 s=4,c=1,t=25,pt=0,l=5,sg=0,st=ok:17:30
send: 7-7-0-0 s=5,c=1,t=37,pt=2,l=2,sg=0,st=ok:70
send: 7-7-0-0 s=5,c=1,t=35,pt=2,l=2,sg=0,st=ok:59
send: 7-7-0-0 s=2,c=1,t=37,pt=2,l=2,sg=0,st=ok:15
send: 7-7-0-0 s=2,c=1,t=35,pt=2,l=2,sg=0,st=ok:15
send: 7-7-0-0 s=10,c=1,t=24,pt=0,l=20,sg=0,st=ok:2016/01/29 23:30:34
send: 7-7-0-0 s=6,c=1,t=0,pt=7,l=5,sg=0,st=ok:10.6
send: 7-7-0-0 s=6,c=1,t=1,pt=7,l=5,sg=0,st=ok:37.9
send: 7-7-0-0 s=7,c=1,t=0,pt=7,l=5,sg=0,st=ok:10.0
2016/01/29 23:30:34 Light level: 59
Hey @Connor-Rigby
Here are my findings...
Compilation perfect, no issues.
The changes to the gateway example I used were just pin configurations:
#define MY_RF24_CE_PIN 9
#define MY_RF24_CS_PIN 10
#define MY_RF24_CHANNEL 111
...
#define MY_CC3000_CS 8
#define MY_CC3000_VBAT 5
#define MY_CC3000_IRQ 3
It starts up like this:
255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
0;255;3;0;9;Radio init successful.
Starting WiFi
CC3000 Started
Connected
Got IP
0;255;3;0;9;Init complete, id=0, parent=0, distance=0
All good.
I wanted to tell me what was my IP address so I've added these lines to the MyGatewayTransportEthernet.ccp
MY_SERIALDEVICE.print(F("\nIP Addr: ")); cc3000.printIPdotsRev(ipAddress);
MY_SERIALDEVICE.print(F("\nNetmask: ")); cc3000.printIPdotsRev(netmask);
MY_SERIALDEVICE.print(F("\nGateway: ")); cc3000.printIPdotsRev(gateway);
MY_SERIALDEVICE.print(F("\nDHCPsrv: ")); cc3000.printIPdotsRev(dhcpserv);
MY_SERIALDEVICE.print(F("\nDNSserv: ")); cc3000.printIPdotsRev(dnsserv);
MY_SERIALDEVICE.println();
But the results were not what I expected
255;3;0;9;Starting gateway (RNNGA-, 2.0.0-beta)
0;255;3;0;9;Radio init successful.
Starting WiFi
CC3000 Started
Connected
Got IP
IP Addr: 8.0.0.1
Netmask: 0.255.252.225
Gateway: 168.1.6.0
DHCPsrv: 0.0.168.168
DNSserv: 225.252.255.115
0;255;3;0;9;Init complete, id=0, parent=0, distance=0
Strange...
Any way I've fixed the ip address on my router
and can ping it from a terminal
RVB:~ rvb$ ping 10.0.0.7
PING 10.0.0.7 (10.0.0.7): 56 data bytes
64 bytes from 10.0.0.7: icmp_seq=0 ttl=64 time=4.674 ms
64 bytes from 10.0.0.7: icmp_seq=1 ttl=64 time=19.361 ms
64 bytes from 10.0.0.7: icmp_seq=2 ttl=64 time=4.335 ms
64 bytes from 10.0.0.7: icmp_seq=3 ttl=64 time=9.256 ms
64 bytes from 10.0.0.7: icmp_seq=4 ttl=64 time=7.163 ms
64 bytes from 10.0.0.7: icmp_seq=5 ttl=64 time=10.054 ms
64 bytes from 10.0.0.7: icmp_seq=6 ttl=64 time=24.724 ms
64 bytes from 10.0.0.7: icmp_seq=7 ttl=64 time=4.882 ms
^C
--- 10.0.0.7 ping statistics ---
8 packets transmitted, 8 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 4.335/10.556/24.724/7.046 ms
I'm also able to send commands via MYSController
0;255;3;0;9;Eth: connect
0;255;3;0;9;Eth: 0;0;1;0;0;123
0;255;3;0;9;Eth: 0;0;1;0;0;456
0;255;3;0;9;Eth: 0;0;1;0;0;789
So Kudos Mr. @Connor-Rigby you did it, excellent work!!
And since we love pictures...
Cheers
Hey @Connor-Rigby
I will try it for sure.
But one question when I go to https://github.com/PressY4EKG/Arduino/blob/2177387fc4f388de02f60cd4698f62e4a200fefe/libraries/MySensors/core/MyHwCC3000.cpp
Its empty...
Does this mean you're using the CC3000 libraries directly?
@cranky ,
do you have a git repository where we can download all the stuff?
Hi @flopp
I think cc3000 disconnects from the Wifi and as @Connor-Rigby mentioned in his post there is some work to be done on that area.
This is actually a MAC-weirdness... no worries.
Well it connected to the amazon MQTT server no problems there.
But i don't have my gateway with me, will test later.
Thanks!
as you can see on my log the npm install does not return any errors.
I had to manually create a nodes directory and install the files manually.
Anyway I guess I don't need it anymore since you removed the dependency
Thanks
Cheers
Hi @cranky
I'm very interested in this.
I was about to start coding a nodeJS app to create a SerialMQTTGateway
I'm going to try yours...
Actually first snag...
I can't get the node-red-contrib-mysensor installed...
So the mysencdec is missing
Any tips?
Here is my log:
RVB:~/.node-red rvb$ pwd
/Users/rvb/.node-red
RVB:~/.node-red rvb$ npm install node-red-contrib-mysensors
node-red-contrib-mysensors@0.7.5 ../node_modules/node-red-contrib-mysensors
RVB:~/.node-red rvb$ node-red -v
Welcome to Node-RED
===================
13 Jan 10:12:44 - [info] Node-RED version: v0.12.5
13 Jan 10:12:44 - [info] Node.js version: v0.12.2
13 Jan 10:12:44 - [info] Loading palette nodes
13 Jan 10:12:45 - [warn] ------------------------------------------
13 Jan 10:12:45 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
13 Jan 10:12:45 - [warn] ------------------------------------------
13 Jan 10:12:45 - [info] Settings file : /Users/rvb/.node-red/settings.js
13 Jan 10:12:45 - [info] User directory : /Users/rvb/.node-red
13 Jan 10:12:45 - [info] Flows file : /Users/rvb/.node-red/flows_RVB.local.json
13 Jan 10:12:45 - [info] Server now running at http://127.0.0.1:1880/
13 Jan 10:12:45 - [info] Starting flows
13 Jan 10:12:45 - [info] [inject:462ebb50.b9d144] repeat = 300000
13 Jan 10:12:45 - [info] Started flows
What am I doing wrong?
Cheers
If you're not using 1.6 i think @Connor-Rigby has what you need
Check this out http://forum.mysensors.org/topic/2727/adafruit-cc33000-wifigateway
@Connor-Rigby very interesting.
A good candidate to port to 1.6, if you're interested check this out http://forum.mysensors.org/topic/2709/mysensors-wifi-gateway-with-arduino-uno-and-cc3000
Thanks for sharing
Hi @flopp
I've tried my CC3000 shield again with no luck, it just does not initialize.
However at the time I got another board with just the CC3000 and it does work, I was able to connect it to my Wifi and ping a server.
Also did some investigation on what it would take to have this module working with MySensors on 1.6
This would imply changes on the core libraries, something I don't feel comfortable without support from the MySensors folks.
But let me explain my rationale:
We should be able to create a CC3000 gateway similar to WL5100 or even ESP8266 and from there we could go to the MQTT client.
At the core we have the ethernet transport library:
Here is a snippet:
#if defined(MY_GATEWAY_ESP8266)
// Some re-defines to make code more readable below
#define EthernetServer WiFiServer
#define EthernetClient WiFiClient
#define EthernetUDP WiFiUDP
#if defined(MY_IP_ADDRESS)
IPAddress gateway(MY_IP_GATEWAY_ADDRESS);
IPAddress subnet(MY_IP_SUBNET_ADDRESS);
#endif
static bool clientsConnected[MY_GATEWAY_MAX_CLIENTS];
It should be possible to so something like:
#if defined(MY_GATEWAY_CC3000)
// Some re-defines to make code more readable below
#define EthernetServer Adafruit_CC3000_Server
#define EthernetClient Adafruit_CC3000_Client
//#define EthernetUDP WiFiUDP
#if defined(MY_IP_ADDRESS)
IPAddress gateway(MY_IP_GATEWAY_ADDRESS);
IPAddress subnet(MY_IP_SUBNET_ADDRESS);
#endif
static bool clientsConnected[MY_GATEWAY_MAX_CLIENTS];
Of course we would need to port whatever methods are called from those EthernetClient/Server to the Adafruit_CC3000_Client/Server.
However later in the code we have a "mysterious" WiFi object that I just cant find where is it coming from...
bool gatewayTransportInit() {
_w5100_spi_en(true);
#if defined(MY_GATEWAY_ESP8266)
(void)WiFi.begin(MY_ESP8266_SSID, MY_ESP8266_PASSWORD);
#ifdef MY_IP_ADDRESS
WiFi.config(_ethernetGatewayIP, gateway, subnet);
#endif
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
MY_SERIALDEVICE.print(".");
yield();
}
MY_SERIALDEVICE.print(F("IP: "));
MY_SERIALDEVICE.println(WiFi.localIP());
I suppose this would be inside the ESP8266.h or similar.
I do have the Adafruit_CC3000 library and for this to work we have to declare and instantiate a CC3000 object, something like
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2); // you can change this clock speed but DI
And the we could call
cc3000.begin()
...
cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)
...
etc
But where to do this?
On a lib under drivers, included when we define a MY_GATEWAY_CC3000 like the NRF drivers?
#if defined(MY_RADIO_NRF24)
#if defined(MY_RF24_ENABLE_ENCRYPTION)
#include "drivers/AES/AES.cpp"
#endif
#include "drivers/RF24/RF24.cpp"
#include "core/MyTransportNRF24.cpp"
Or maybe a MyHwCC3000 ?
Perhaps @hek and the other folks can point us in the right direction
Cheers
That is funny.
I read that post and gave him a link to my sensors.
I guess I wasnt the only one
I'm sorry @flopp
It did not work on the end, my shield just stopped working even with an example sketch, so I never completed the project.
What flavor of CC3000 do you have, the shield with the SD card or the small board with just the wifi module?
Cheers
@Mihai, I see.
As @Yveaux said, this is a refactor / change in architecture from 1.5 to 1.6
For example:
The serial gateway from 1.5 (setup and loop):
void setup()
{
gw.begin(incomingMessage, 0, true, 0);
setupGateway(INCLUSION_MODE_PIN, INCLUSION_MODE_TIME, output);
// Add interrupt for inclusion button to pin
PCintPort::attachInterrupt(pinInclusion, startInclusionInterrupt, RISING);
// Send startup log message on serial
serial(PSTR("0;0;%d;0;%d;Gateway startup complete.\n"), C_INTERNAL, I_GATEWAY_READY);
}
void loop()
{
gw.process();
checkButtonTriggeredInclusion();
checkInclusionFinished();
if (commandComplete) {
// A command wass issued from serial interface
// We will now try to send it to the actuator
parseAndSend(gw, inputString);
commandComplete = false;
inputPos = 0;
}
}
Serial gateway from 1.6 (set up loop and new presentation section):
void setup() {
// Setup locally attached sensors
}
void presentation() {
// Present locally attached sensors
}
void loop() {
// Send locally attached sensor data here
}
Cheers
I'm not sure I follow your question.
The 1.6 dev environment has GatewayW5100MQTTClient here: https://github.com/mysensors/Arduino/tree/development/libraries/MySensors/examples/GatewayW5100MQTTClient
You can see the actual protocol in actions here: https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/core/MyGatewayTransportMQTTClient.cpp
Cheers
Hi @samuel235
I guess i've tried to re-invent the wheel.
What you see is a controller developed by me. Each "card"represents a sensor with messages inside, as long as they are of different type. This seems to be a design flaw, I've made it too flexible and UI wise is a nightmare.
They are grouped by nodes.
The image I've posted is from a phone for factor. It looks like this on anormal screen:
After this experiment, one sensor one message seems to be the way to go.
I'm also starting to experiment with openHab
Cheers
Hi @pelnarp
Yes i do have the vanila serial gateway.
I run the nodeJS on a windows computer or on a raspberry pi depending on my setup, anyway nodeJS is available for may operating system flavors and the code run on all of them.
You just need to adjust the com port on this line
var serialPort = new com.SerialPort('COM3', {
baudrate: 115200,
parser: com.parsers.readline('\n')
});
Where it says COM3 (this is windows) in mac it will be similar to /dev/cu.usbmodem14141 and in raspberry pi or linux something like /dev/ttyACM0 representing the port where you have it connected.
I use an authentication header to prevent tampering with the RESP API, I strongly reccomend you set up something similar if like me the REST API is on the cloud.
And to receive the commands this nodeJS app also exposes a REST API which sends the commands back to serial gateway.
Here are the files package.json gw.js, have fun!
Anyway some food for though.
I've seen folks here use a lot of MQTT, seems to be a very popular protocol for IOT and this type of stuff.
The only reason I'm not using it is because I do not have a WL500 module for a ethernet gateway, I've tried with adafruit CC3000 with no success yet.
Perhaps building a nodeJS app to translate the serial from MySensors to MQTT might be a good idea...
Cheers
Hi folks,
Quick update on my progress.
I was wondering how other controllers could handle this situation.
If anyone has some input I would appreciate the feedback.
Here is how I split the nodes and messages.
Had to combine V_LEVEL with other messages such as V_VOLUME in order to have 2 similar messages on the same sensor.
I wonder if "normal"controllers just treat one message one sensor?
Cheers
I use something similar but it is on a serial gateway.
I use a simple nodeJS program running where the serial gateway is connected.
It reads from serial and sends to a REST api.
If you're interested in this example I'll gladly share it.
I've also seen folks using node-red to split the incoming messages and send it to more than one place, but i think it is serial gateway too.
Cheers
All the best to this community!!!
Cheers
Hi Folks
I got a question for the community.
There is no Hydroponics dedicated sensor id in MySensors Lib and probably the same with the controllers out there.
What would be better:
So for now what I need to report and manage is:
So far I'm using...
MyMessage msgPump(MY_PUMP_ID, V_STATUS);
MyMessage msgLight(MY_PUMP_ID, V_LEVEL);
MyMessage msgTime(MY_PUMP_ID,V_VAR1);
Thanks
Hi Folks,
The guys at MySensors were kind to convert this to 1.6 lib.
So being back in Europe for the holidays I decided to create a post with some explanations/tutorial about the code.
This example MockMySensors from the MySensors examples actually combines 30 sensors in a single node.
It may have a poor architecture but it will give you an idea of how to combine sensors and with some feedback we can always improve on the architecture.
It has been designed for you to customize it for the sensor you want to test by uncomment the initial lines.
This line defines your NODE ID, you can always change it to AUTO or to your specification
#define MY_NODE_ID 254
This part of the code defines the sensors you want to work with and their ids
#define ID_S_ARMED 0 // dummy to controll armed stated for several sensors
#define ID_S_DOOR 1
//#define ID_S_MOTION 2
//#define ID_S_SMOKE 3
//#define ID_S_LIGHT 4
//#define ID_S_DIMMER 5
//#define ID_S_COVER 6
//#define ID_S_TEMP 7
//#define ID_S_HUM 8
//#define ID_S_BARO 9
... code lines snipped ...
//#define ID_S_MOISTURE 33
//
//#define ID_S_CUSTOM 99
This part of the code defines the messages you want to instantiate to work with your sensors
#ifdef ID_S_DOOR // V_TRIPPED, V_ARMED
MyMessage msg_S_DOOR_T(ID_S_DOOR,V_TRIPPED);
MyMessage msg_S_DOOR_A(ID_S_DOOR,V_ARMED);
#endif
#ifdef ID_S_MOTION // V_TRIPPED, V_ARMED
MyMessage msg_S_MOTION_A(ID_S_MOTION,V_ARMED);
MyMessage msg_S_MOTION_T(ID_S_MOTION,V_TRIPPED);
#endif
#ifdef ID_S_SMOKE // V_TRIPPED, V_ARMED
MyMessage msg_S_SMOKE_T(ID_S_SMOKE,V_TRIPPED);
MyMessage msg_S_SMOKE_A(ID_S_SMOKE,V_ARMED);
#endif
#ifdef ID_S_LIGHT
MyMessage msg_S_LIGHT(ID_S_LIGHT,V_LIGHT);
bool isLightOn=0;
#endif
... code lines snipped ...
#ifdef ID_S_MOISTURE
// To be implemented
#endif
On the presentation section, you have all the sensors being presented, along with some debugging
void presentation() {
#ifdef ID_S_DOOR
Serial.println(" S_DOOR");
present(ID_S_DOOR,S_DOOR,"Outside Door");
wait(SHORT_WAIT);
#endif
#ifdef ID_S_MOTION
Serial.println(" S_MOTION");
present(ID_S_MOTION,S_MOTION,"Outside Motion");
wait(SHORT_WAIT);
#endif
#ifdef ID_S_SMOKE
Serial.println(" S_SMOKE");
present(ID_S_SMOKE,S_SMOKE,"Kitchen Smoke");
wait(SHORT_WAIT);
#endif
... code lines snipped ...
#ifdef ID_S_CUSTOM
Serial.println(" S_CUSTOM");
present(ID_S_CUSTOM,S_CUSTOM,"Other Stuff");
wait(SHORT_WAIT);
#endif
On the loop section you have methods which will trigger each sensor to report. This will happen periodically on the SLEEP_TIME, 15 minutes by default
void loop()[
//Read Sensors
#ifdef ID_S_DOOR
door();
#endif
#ifdef ID_S_MOTION
motion();
#endif
#ifdef ID_S_SMOKE
smoke();
#endif
... code lines snipped ...
#ifdef ID_S_CUSTOM
custom();
#endif
Lets take a look at one of them, the dimmer. As you can see its just reporting the dimmerVal which was declared as a global variable.
Sometimes these values are saved in the EPROM, for this example I wanted to avoid that.
#ifdef ID_S_DIMMER
void dimmer(){
Serial.print("Dimmer is set to: " );
Serial.println(dimmerVal);
send(msg_S_DIMMER.set(dimmerVal));
}
#endif
Finally the incoming message section.
void receive(const MyMessage &message) {
... code lines snipped ...
#ifdef ID_S_DIMMER
case V_DIMMER:
if ((message.getInt()<0)||(message.getInt()>100)) {
Serial.println( "V_DIMMER data invalid (should be 0..100)" );
break;
}
dimmerVal= message.getInt();
Serial.print("Incoming change for ID_S_DIMMER:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getInt());
dimmer();// temp ack
break;
#endif
... code lines snipped ...
The temp ack mean I'm just forcing the sensor to report back the new value to the controller.
And this is basically what it takes to combine sensors in the MySensors library.
One node can have many sensors and each sensor can receive any number or combinations of messages.
So for the dimmer example
#define ID_S_DIMMER 5
... code lines snipped ...
#ifdef ID_S_DIMMER
MyMessage msg_S_DIMMER(ID_S_DIMMER,V_DIMMER);
int dimmerVal=100;
#endif
... code lines snipped ...
void presentation() {
... code lines snipped ...
#ifdef ID_S_DIMMER
Serial.println(" S_DIMMER");
present(ID_S_DIMMER,S_DIMMER,"Living room dimmer");
wait(SHORT_WAIT);
#endif
... code lines snipped ...
There is nothing stoping me to add another message type to the dimmer. So for example if the dimmer does have an on/off button I could add
MyMessage msg_S_DIMMER_BUTTON(ID_S_DIMMER,V_STATUS)
Note that your controller might not be expecting all this freedom of combinations of messages.
So although I could report a temperature on a dimmer sensor using
MyMessage msg_S_DIMMER_BUTTON(ID_S_DIMMER,V_TEMP)
Your controller might not like it.
As always feddback is welcome
Cheers
Hi Folks
Here is a first update on this project.
First some pictures of the hardware.
(please ignore the dying plants, they are from another experiment)
The plant fountain was 100% home designed and printed and I added a 5 gallon bucket, lid and pump inside. The electronics are not connected yet.
And my development/test electronics
Arduino, relay for the pump and an RTC module
This will allow me to complete phase 1 which is basically running the pump for x minutes, stoping for y minutes during a time interval (e.g. 8am 6pm)
This first pump module is obviously using MySensors and although I want it to work independently of a controller i'm using MySensor to report data and implement some commands.
I've tried to do things with some architecture, using classes but C++ is still a bit of a mystery to me, so feedback is welcome as always.
The current and planned architecture goes as follows:
Hydro.ino Module
/**
**/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enabled repeater feature for this node
//#define MY_REPEATER_FEATURE
// Define Node ID
#define MY_NODE_ID 7
// INCLUDES //
#include <SPI.h>
#include <MySensor.h>
#include <Bounce2.h>
#include <Time.h>
#include <DS1302RTC.h> // A DS3231/DS3232 library
#include "HydroConfig.h"
#include "MyPump.h"
// Skecth name and version
#define SKETCH_NAME "Hydro9"
#define SKETCH_VERSION "v0.1"
// Pin Assignments
#define BUTTON_PIN 4 // Arduino Digital I/O pin number for button
Bounce debouncer = Bounce();
int oldValue = 0;
unsigned long lastUpdate = 0;
MyMessage msgPump(MY_PUMP_ID, V_STATUS);
MyPump myPump(MY_PUMP_RELAY_PIN);
void setup()
{
// Setup the button
pinMode(BUTTON_PIN, INPUT);
// Activate internal pull-up
digitalWrite(BUTTON_PIN, HIGH);
// After setting up the button, setup debouncer
debouncer.attach(BUTTON_PIN);
debouncer.interval(5);
myPump.rtc_init();
// Request latest time from controller at startup
requestTime();
wait(2000);// Wait for time form controller
Serial.print("Current time: ");
Serial.println(myPump.currentDateTime().c_str());
myPump.pumpCycleRun(1);
myPump.pumpCycleStop(1);
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
// Register all sensors to gw (they will be created as child devices)
present(MY_PUMP_ID, S_BINARY, "Pump");
}
void loop()
{
debouncer.update();
// Get the update value
int value = debouncer.read();
if (value != oldValue && value == 0) {
send(msgPump.set(myPump.pumpSwitch()), false);
}
oldValue = value;
if(myPump.pumpCheck())
{
send(msgPump.set(myPump.isOn()), false);
}
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.isAck()) {
Serial.println("This is an ack from gateway");
}
if (message.type == V_STATUS) {
// Change relay state
if (message.getBool())
myPump.pumpOn();
else
myPump.pumpOff();
send(msgPump.set(myPump.isOn()), false);
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
}
void receiveTime(unsigned long controllerTime)
{
myPump.rtc_set(controllerTime);
}
MyPump Module:
Here is the pump running at 1 minute on, 1 minute off cycle
Starting sensor (RNNNA-, 1.6.0-beta)
Radio init successful.
RTC module activated
RTC Sync TieStatus: 2 timeSet 2 Ok!
send: 7-7-0-0 s=255,c=3,t=1,pt=0,l=0,sg=0,st=ok:
Current time: 2015/12/12 16:28:55
send: 7-7-0-0 s=255,c=0,t=17,pt=0,l=10,sg=0,st=ok:1.6.0-beta
send: 7-7-0-0 s=255,c=3,t=6,pt=1,l=1,sg=0,st=ok:0
send: 7-7-0-0 s=255,c=3,t=11,pt=0,l=6,sg=0,st=ok:Hydro9
send: 7-7-0-0 s=255,c=3,t=12,pt=0,l=4,sg=0,st=ok:v0.1
send: 7-7-0-0 s=1,c=0,t=3,pt=0,l=4,sg=0,st=ok:Pump
Init complete, id=7, parent=0, distance=1
2015/12/12 16:29:52 PUMP ON
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
2015/12/12 16:30:52 PUMP OFF
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
2015/12/12 16:31:52 PUMP ON
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
2015/12/12 16:32:52 PUMP OFF
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
2015/12/12 16:33:52 PUMP ON
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
2015/12/12 16:34:53 PUMP OFF
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:0
2015/12/12 16:35:52 PUMP ON
send: 7-7-0-0 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1
Again, feedback is welcome
Cheers
HI
I've been trying vs code
It has GIT integration, Arduino file format and some auto complete.
It is also capable of verifying and uploading the sketch
Cheers
@Dwalt thank for the tip.
I was thinking on having low and high water sensor on the deposit, not sure where I would put the leak sensors.
Let me give you more context, I'm trying to build something like a tower, so if it leaks it will go into the top of the deposit, perhaps I can create some sort of draining system.
Here are some drawings
This is the top lid
This is the top structure (the lid goes here) and it acts like a shower
This is the main body with 3in cups version
and this is the base for the body
The idea is to print bodies and bases and then one top and one lid.
The pump connects from below to the base, pumping water up to the lid which in turn will come down.
The body cup holders should be staggered.
I'm thinking of creating another base to include some kind of filter and connectors to the water deposit.
For water deposit im thinking of a 5 gallon food bucket with lid
Something like this
Hi @haze5 ,
I'm working on a hydroponic sensor, would you give me some feed back on my RFC?
Also would you be interested in working on this toguether?
Cheers
Hi Folks,
I've been thinking on the creation of a Hydroponics sensor to be used in the context of the MySensors network.
After some time adjusting the design for 3D printing the parts I'm starting to look at how to monitor and manage the system.
I have a rough idea of what it should monitor and do but would like the inputs from this community since there are plety of folks with experience managing gardens and plants.
Data to monitor:
Water PH Level - Should be kept between 5.5 and 6.5 depending on the plant
Water TPM/PPM - Measure the ammount of nutrients still in the water. It will also measure dirt and other solid contaminants
Water temperature - Cooler water holds more oxygen which seems to be important for the roots and also warmer water holds more bacteria which will also affect root health.
Water Level On Deposit - MAx and Min Level
Water Oxygen Level
Actions:
Circulate Water - Pump to send the water to the roots (something like 15 minutes on 15 minutes off)
Balance PH by adding accid or alcaline solution - Probably using 2 peristaltic liquid pumps
Mix/Agitate Water - When adding the PH solution it is important to mix the water - This could be achieved with the same pump and a solenoid valve sending the water to a recirculating circuit
Add nutrients - Add nutrient solution up to the desired PPM level bu using another peristaltic pump
Filter Water
Add water to deposit
Purge water from deposit
Can you think of more item to measure or possible actions?
Cheers
arghhh of course, it will be very dificult geting pass the radio init fail...
Sorry, I pointed you in the wrong direction.
I use nodeJS to read from the serial gatweay and send the information to my my controller HAALL, similar to what @tbowmo is suggesting.
Now depending on how your controller accepts information you might pull this off with some hacking. (In HAALL case it accepts via REST service). I've attached my nodeJS example for convenience.
Cheers
@TheoL as a point.
However once you try it you might start to get into some hardware limitations.
Smaler arduinos have less memory and pins and you're probably bound to hit one of those.
I've tried to put all sensors in a sigle skecth. On ardiuno uno its gets about 12 before memory is exausted and you dont have 12 pins available. On a mega memory is fine (about 30 sensors) and you also have plenty of pins.
Of course you can work around not having enough pins as this example of the irrigation controller
Cheers
@bpair the SPI pins are different on a mega (see here)
MISO - 50
MOSI - 51
SCK - 52
SS - 53
I have a node on a mega and its working fine with the following pins
MISO - 50
MOSI - 51
SCK - 52
CE - 9
CS - 10
CE and CS are configurable in MySensors Library
Cheers
@popunonkok said:
Hmm...
TheoL: That didnt seem to work. I changed to my USBport, using:
sudo cat /dev/ttyUSB0
But that just left me "Hanging" so I hade to Quit that command using Ctrl-C.
Im using SSH by the way.Barduino: Are you meaning that you have your gateway on a Mac? Im running Rasbian Wheezy on my Pi.
Screen is a common utility found in most linux distros, I guess Pi isnt one of them
I connect my gateway to a computer (mac, windows) and then use node.js to send the messages to a controller.
Anyway this http://playground.arduino.cc/Interfacing/LinuxTTY is a really good post on how to monitor your usb/serial on a linux
The sudo cat /dev/xxxyyyy does not work on my mac but i suspect is because of the baud rate
RVB:~ rvb$ sudo cat /dev/cu.usbmodem1411
Password:
s1??~???ےIq~???s1q?^???
but with the
RVB:~ rvb$ screen /dev/cu.usbmodem1411 115200
i get
0;0;3;0;9;gateway started, id=0, parent=0, distance=0
0;0;3;0;14;Gateway startup complete.
Either way make sure you are selecting the correct /dev/xxxyyy device and nothing else is connected to it (serial monitor of the arduino ide etc)
This is also a good post on how to monitor serial port an PI
http://raspberrypi.stackexchange.com/questions/22181/arduino-serial-port-via-raspberry-pi-ssh
Cheers
I'm not sure what flavor of linux the raspberry Pi has, so it may not have all the utilities of a standard one.
This works on my mac: screen /dev/cu.usbmodem1421 115200
Here is an article with several ways to accomplish this
Cheers
Absolutely! In fact it has been available since day 1.
Check this post
Since this is developed using a Platform you need to do some steps to set it up:
and just hack away.
I never had a chance to explore the northen countries, folks say its beutifull landscape and nice people.
perhaps some day.
Picture this scenario:
You have an alarm system for you house based on MySensors.
You have sensors to detect if the door and windows are open. Once they are open you trigger some kind of alarm if the system is not turned off.
Also you might want to be able to open the windows or door and have the alarm off.
The V_TRIPPED would detect if the door or windowsa are opened and the V_ARMED would control if the alarm is on or off.
So ye, the V_ARMED would be turned on and off via incoming message and you would find out if you need to trigger the alarm by looking t both variables.
As for implementation examples you have plenty under /libraries/MySensors/Examples.
There is also one example wich has fake implementations of almost all sensors . This was designed to help developers test or implement controllers but it has also been a nice learning exercise.
Cheers
@NeverDie Ihave one of these and im very happy with it