Skip to content

Commit caf7936

Browse files
committed
Add support for Seeeduino Stalker v3.1 to Open Hive GSM sensor node firmware
1 parent 1779487 commit caf7936

File tree

1 file changed

+76
-21
lines changed

1 file changed

+76
-21
lines changed

node-gprs-http/node-gprs-http.ino

Lines changed: 76 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
transp: | GSM via HTTP
1111
| WiFi via HTTP (ESP8266)
1212
13-
Copyright (C) 2013-2017 by Clemens Gruber
13+
Copyright (C) 2013-2019 by Clemens Gruber
1414
1515
1616
Changes
@@ -20,6 +20,7 @@
2020
2016-06-20 Clemens Gruber | Modularization of upload URL
2121
2016-09-17 Clemens Gruber | Modularization of sensors and debugging
2222
2017-01-09 Clemens Gruber | Add support for HX711 and ESP8266
23+
2017-04-30 Clemens Gruber | Add support for Seeeduino Stalker v3.1
2324
2425
2526
GNU GPL v3 License
@@ -44,6 +45,7 @@
4445
D4, D10 Power (LOW is power on), CS - SD
4546
D6, D7 2x DHTxx [out,in]
4647
D8 DS18B20 one-wire array
48+
D9 Power for bee GPRS and 3.3V on Seeeduino Stalker 3.1
4749
D12 D13 DTR, CTS - GSM
4850
D14 D15 D16 Data, SCL, Power - ADS1231
4951
D14 D12 Dour, SCK - HX711 (ESP8266)
@@ -61,10 +63,11 @@
6163
#define isScale
6264
#define isScaleADS1231
6365
//#define isScaleHX711
64-
#define isTemperatureArray
66+
//#define isTemperatureArray
6567
#define isHumidityTemperature
6668
#define isRTC // define for ESP8266 also! gets time from server
6769
//#define isSD
70+
#define isStalker31 // for the updated board Seeeduino Stalker v3.1
6871
#define isBattery
6972

7073
#define isGSM
@@ -73,6 +76,7 @@
7376
#define isWifi
7477
#endif
7578

79+
//#define isWifi
7680
//#define isEthernet
7781
// comments this line in case you are using GSM as upload path
7882
// GSM and Serial debug using the same pins and interfere
@@ -81,10 +85,10 @@
8185
// ** RTC / timekeeping
8286
// --------------------
8387
// update interval for sensor reading in seconds
84-
// unsigned long updateInterval = 60UL * 20; // s*m*h*d
88+
unsigned long updateInterval = 60UL * 60; // s*m*h*d
8589
// ESP8266: maximun update interval is 1 hour due to variable size limitations
8690
// (we'll fix that in a later version)
87-
unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec longer than in theory
91+
//unsigned long updateInterval = 60UL*5UL; // s*m*h*d // seems it take 11 sec longer than in theory
8892

8993
// keep in mind that very low values make no sense here!
9094
// sensor reading takes time, scale reads load multiple to
@@ -98,7 +102,7 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
98102
const char uploadNode[] = "1";
99103
// and user credentials
100104
const char uploadUserName[] = "your-user-name";
101-
const char uploadUserId[] = "your-id";
105+
const char uploadUserId[] = "your-user-id";
102106
// server, path and upload script
103107
const char uploadDomain[] = "data.example.com";
104108
const char uploadFolderFile[] = "apiary/upload.php";
@@ -109,15 +113,15 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
109113
// ----------------
110114
#ifdef isGSM
111115
// specify your APN here, specific for your network operator
112-
#define APN "internet.eplus.de"
116+
#define APN "internet.telekom"
113117
#endif
114118

115119
// ** WiFi
116120
// -------
117121
#ifdef isWifi
118122
// specify your SSID an PW here, specific for your local WiFi
119-
#define WLAN_SSID "your-ssid"
120-
#define WLAN_PW "your-pw"
123+
#define WLAN_SSID "your-wifi-ssid"
124+
#define WLAN_PW "your-wifi-pass"
121125
#endif
122126

123127
// ** load cell characteristic
@@ -134,10 +138,12 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
134138
// add a load with known weight in kg to the scale, note the
135139
// sesor value, calculate the value for a 1 kg load and adjust
136140
// it here
137-
const long loadCellZeroOffset = 38623;
138-
// const long loadCellKgDivider = 22053;
139-
// 1/2 value for single side measurement, so that 1 kg is displayed as 2 kg
140-
const long loadCellKgDivider = 11026;
141+
142+
// Note: Use 1/2 value for single side measurement,
143+
// so that 1 kg is displayed as 2 kg.
144+
145+
const long loadCellZeroOffset = 50682624;
146+
const long loadCellKgDivider = 5895655;
141147

142148
// wait between samples
143149
// 3 sec is a good delay so that load cell did not warm up
@@ -168,7 +174,7 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
168174
// how much pins have DHTxx devices connected?
169175
const int humidityNumDevices = 1;
170176
// pins with DHTxx device, pin 6, pin 7
171-
const int humidityPins[humidityNumDevices] = {4};
177+
const int humidityPins[humidityNumDevices] = {6};
172178
#endif
173179

174180
// ** temperature array / DS18B20
@@ -185,15 +191,15 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
185191
// resolution for all devices (9, 10, 11 or 12 bits)
186192
const int temperaturePrecision = 12;
187193
// pin for the temperature sensors
188-
const int temperaturePin = 5;
194+
const int temperaturePin = 7;
189195
#endif
190196

191197
// ** SD card
192198
// ----------
193199
#ifdef isSD
194200
// data upload to server, path and file
195-
const char sdStorageUploadPath[] = "/upload2/";
196-
const char sdStorageUploadFile[] = "d-new.txt";
201+
const char sdStorageUploadPath[] = "/upload/";
202+
const char sdStorageUploadFile[] = "new-data.txt";
197203

198204
// data archive, path
199205
const char sdStorageArchivePath[] = "/archive/";
@@ -207,7 +213,8 @@ unsigned long updateInterval = 60UL * 60UL; // s*m*h*d // seems it take 11 sec
207213
// do not use spaces before or after an comma
208214
//const char datasetHeader[] = "Date/Time,Weight,Outside Temp,Outside Humid,Inside Temp,Inside Humid,H1 Temp,H2 Temp,H3 Temp,H4 Temp,H5 Temp,Voltage";
209215
//const char datasetHeader[] = "Date/Time,Weight,Outside Temp,Outside Humid,Inside Temp,Voltage";
210-
const char datasetHeader[] = "Datum/Zeit,Gewicht,Aussen-Temperatur,Aussen-Feuchtigkeit,Brut-Temperatur,Spannung";
216+
//const char datasetHeader[] = "Datum/Zeit,Gewicht,Aussen-Temperatur,Aussen-Feuchtigkeit,Brut-Temperatur,Spannung";
217+
const char datasetHeader[] = "Datum/Zeit,Gewicht,Aussen-Temperatur,Aussen-Feuchtigkeit,Batterie-Spannung";
211218

212219
// -------------------------+----
213220
// variables you can modify | END
@@ -295,7 +302,7 @@ const char datasetHeader[] = "Datum/Zeit,Gewicht,Aussen-Temperatur,Aussen-Feucht
295302
OneWire oneWire(temperaturePin); // oneWire instance to communicate with any OneWire devices (not just DS18B20)
296303
DallasTemperature temperatureSensors(&oneWire); // pass oneWire reference to DallasTemperature
297304
uint8_t deviceAddressArray[temperatureNumDevices][8]; // arrays for device addresses
298-
const char gradC[4]={' ','°','C','\0'}; // degree sign
305+
const char gradC[4]={' ','d','C','\0'}; // degree sign
299306
#endif
300307

301308
// power saving
@@ -356,6 +363,17 @@ const char datasetHeader[] = "Datum/Zeit,Gewicht,Aussen-Temperatur,Aussen-Feucht
356363

357364

358365
void setup () {
366+
367+
// power switching Stalker board version 3.1
368+
#ifdef isStalker31
369+
// in version 3.1 of the Seeeduino Stalker a power switching pin
370+
// for 3.3 V and the GPRS pins / bee socket was introduced:
371+
// set pin 9 high to switch power on
372+
pinMode(9, OUTPUT);
373+
digitalWrite(9, HIGH);
374+
delay(500);
375+
#endif
376+
359377
// debug and GSM
360378
Serial.begin(9600);
361379
#ifdef isDebug
@@ -576,6 +594,12 @@ void setup () {
576594
interruptTime = DateTime(start.get() + updateInterval);
577595
#endif
578596
#endif
597+
598+
// switch power off for 3.3 V pin and bee socket
599+
#ifdef isStalker31
600+
Serial.flush();
601+
digitalWrite(9, LOW);
602+
#endif
579603
}
580604

581605

@@ -854,12 +878,16 @@ void setup () {
854878
// read the battery level from the analog pin.
855879
//
856880
// ** for Lipo 4.2V
881+
// * Seeeduino Stalker has 10M and 2M voltage divider resistors
882+
//
883+
// * Open Hive Wifi Solar (ESP8266) and Open Hive ProMini Solar
857884
// Our 1M & 220K voltage divider takes the max lipo value of
858885
// 4.2V and drops it to 0.757V max. This means our min analog
859886
// read value should be 580 (3.14V / 0.566V) and the max analog
860887
// read value should be 774 (4.2V / 0.757).
861888
//
862889
// ** for 4x 1,5 V AA battery = 6 V
890+
// * Open Hive Wifi (ESP8266) and Open Hive ProMini with battery
863891
// Our 1.5M & 220K voltage divider takes the max battery value of
864892
// 6V and drops it to 0.767V max. This means our min analog
865893
// read value should be 411 (3.14V / 0.402V) and the max analog
@@ -868,13 +896,16 @@ void setup () {
868896
void getVoltage() {
869897
int batteryValue = analogRead(batteryPin); // read battery as analog value
870898

899+
// Set voltage divider based on device and operation mode, values are in Mega Ohm
900+
//float voltageDivider = (analogMax / 1024) * (1.5 + 0.22) / 2; // Open Hive Battery
901+
//float voltageDivider = (analogMax / 1024) * (1 + 0.22) / 2; // Open Hive Solar
902+
float voltageDivider = (analogMax / 1024) * (10 + 2) / 2; // Seeeduino Stalker
903+
871904
// Compute voltage based on voltage divider resistors
872-
float voltage = batteryValue * (analogMax / 1024) * (10 + 2) / 2; // voltage divider, values in Mega Ohm
905+
float voltage = batteryValue * voltageDivider;
873906

874907
// Write to char array
875908
dtostrf(voltage,5,2,voltageChar); // write to char array
876-
877-
878909
}
879910
#endif
880911

@@ -896,6 +927,17 @@ void setup () {
896927
// ------------
897928

898929
void loop () {
930+
// switch power for 3.3 V pin and bee socket on
931+
#ifdef isStalker31
932+
digitalWrite(9, HIGH);
933+
// wait for stabilizing
934+
delay(500);
935+
936+
// change pinmode for 0,1 to default
937+
// pinMode(0, INPUT);
938+
// pinMode(1, OUTPUT);
939+
#endif
940+
899941
// update data
900942
//
901943
// update timestamp
@@ -1092,6 +1134,7 @@ void loop () {
10921134
delay(400);
10931135
}
10941136
}
1137+
10951138
// go sleeping
10961139
unsigned long runningTime = millis() * 1000UL; // in us!
10971140
unsigned long sleepTime = (updateInterval * 1000UL*1000UL) - runningTime; // s (*ms*us)
@@ -1122,6 +1165,18 @@ void loop () {
11221165
writeToSd(dataset);
11231166
#endif
11241167

1168+
// switch power off for 3.3 V pin and bee socket
1169+
#ifdef isStalker31
1170+
// power off
1171+
digitalWrite(9, LOW);
1172+
1173+
// there is also a recommendation to set pin 0 and 1 to
1174+
// input for power saving
1175+
Serial.flush();
1176+
pinMode(0, INPUT);
1177+
pinMode(1, INPUT);
1178+
#endif
1179+
11251180
// manage sleeping and wake up
11261181
//
11271182
#ifdef isRTC

0 commit comments

Comments
 (0)