Skip to content

Commit

Permalink
0.2.3
Browse files Browse the repository at this point in the history
+ NEW BaySIM800 with https support
  • Loading branch information
holzheu committed May 30, 2023
1 parent f972605 commit c2ebe05
Show file tree
Hide file tree
Showing 16 changed files with 1,192 additions and 310 deletions.
46 changes: 21 additions & 25 deletions libraries/BayEOSBoards/RF24RouterBoard.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,20 @@ RTC_Timer2 myRTC;
volatile long rtc_seconds_correct;
#endif

#ifdef GPRS_CONFIG

#if defined(GPRS_CONFIG)
#include <BayTCPSim900.h>
BayGPRS client(Serial, 0); //No Power Pin
#else
#ifdef WLAN_CONFIG
#elif defined(SIM800_CONFIG)
#include <BaySIM800.h>
BaySIM800 client = BaySIM800(Serial);
#elif defined(WLAN_CONFIG)
#include <BayTCPESP8266.h>
BayESP8266 client(Serial, WLAN_PIN);
#else
#else
#include <BaySerial.h>
BaySerialESP client(Serial,WLAN_PIN);
#endif
#endif



Expand Down Expand Up @@ -301,50 +303,42 @@ void initLCB() {
client.setBuffer(myBuffer);
pinMode(POWER_PIN, OUTPUT);
digitalWrite(POWER_PIN, HIGH);
#ifdef GPRS_CONFIG
#define ESP01 0
#if defined(GPRS_CONFIG)
client.readConfigFromStringPGM(PSTR(GPRS_CONFIG));
#else
#ifdef WLAN_CONFIG
#define ESP01 1
#elif defined(SIM800_CONFIG)
client.readConfigFromStringPGM(PSTR(SIM800_CONFIG));
#elif defined(WLAN_CONFIG)
client.readConfigFromStringPGM(PSTR(WLAN_CONFIG));
#else
#define ESP01 1
client.begin(38400);
client.powerUp();
while(client.isReady()){
blinkLED(2);
delay(1500);
}
#ifndef WLAN_CONFIG
#ifdef ROUTER_NAME
while (tx_res=client.setName(ROUTER_NAME)){
if(tx_res==10+strlen(ROUTER_NAME)) break;
blinkLED(tx_res);
delay(tx_res*500+2000);
}
#endif
#endif
client.powerDown();
#endif
// client.begin(9600);
// client.changeIPR(38400);
#endif

blinkLED(2);
blinkLED(3);
adjust_OSCCAL();
#ifdef GPRS_CONFIG
#if defined(GPRS_CONFIG) || defined(SIM800_CONFIG)
delayLCB(1000);
tx_res = client.begin(38400);
if (! tx_res) myRTC.adjust(client.now());
#else
#ifdef WLAN_CONFIG
#elif defined(WLAN_CONFIG)
tx_res = client.begin(38400);
#else
client.powerUp();
tx_res=0;
#endif
#endif

blinkLED(tx_res + 1);
/*
1 == OK
Expand All @@ -356,8 +350,10 @@ void initLCB() {
7 == No SIM Card
*/
delay(2000);

tx_res = client.sendMessage("Router started");
client.startFrame(BayEOS_Message);
client.addToPayload("Router started");
client.writeToBuffer();
tx_res = client.sendMultiFromBuffer();
blinkLED(tx_res + 1);
delay(1000 + tx_res * 500);

Expand Down Expand Up @@ -632,7 +628,7 @@ void checkAction0(void){
#if ESP01
client.powerUp();
#endif
tx_res = client.sendMultiFromBuffer(1000);
tx_res = client.sendMultiFromBuffer(3000);
if(tx_res) tx_error++;
else tx_error=0;
blinkLED(tx_res + 1);
Expand All @@ -646,7 +642,7 @@ void checkAction0(void){

while (! tx_res && myBuffer.available() && ! ISSET_ACTION(0)) {
handleRF24();
tx_res = client.sendMultiFromBuffer(1000);
tx_res = client.sendMultiFromBuffer(3000);
blinkLED(tx_res + 1);
}
} else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ void loop() {
digitalWrite(MCPPOWER_PIN, HIGH);
client.startDataFrame();
for (uint8_t ch = 0; ch < 16; ch++) {
digitalWrite(A1, ch & 0x8);
digitalWrite(A0, ch & 0x4);
digitalWrite(A0, ch & 0x8);
digitalWrite(A1, ch & 0x4);
digitalWrite(A3, ch & 0x2);
digitalWrite(A2, ch & 0x1);
delay(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Sample Sketch to read resistance using
MCP, a 16bit Multiplexer and a preresistor
*/
#define PRERESISTOR 14300.0
const uint8_t rate = 3; //0-3: 12bit ... 18bit
#define MCPPOWER_PIN 6

#include <BayEOSBufferSPIFlash.h>
#define POWER_DIVIDER ((100.0 + 100.0) / 100.0)
#include <MCP342x.h>
MCP342x mcp342x(0);
const byte addr = 0;
const uint8_t gain = 0; //0-3: x1, x2, x4, x8
float span;

SPIFlash flash(8);
BayEOSBufferSPIFlash myBuffer;

#include <BayDebug.h>
BayDebug client(Serial);

#define ACTION_COUNT 1
#include <LowCurrentBoard.h>

void setup()
{
client.begin(9600);
Serial.println("Starting Test");
myBuffer.init(flash); //This will restore old pointers
Serial.print("Flash: ");
Serial.println(flash.getCapacity());
Serial.flush();
//myBuffer.reset(); //This will set all pointers to zero
myBuffer.skip(); //This will move read pointer to write pointer
myBuffer.setRTC(myRTC, 0); //Nutze RTC relativ!
client.setBuffer(myBuffer); //use skip!
initLCB(); //init time2
mcp342x.reset();
pinMode(POWER_PIN,OUTPUT);
digitalWrite(POWER_PIN,HIGH);
mcp342x.storeConf(1, 0); //14bit,0 gain
batLCB = 3.3*analogRead(A7)/1023*POWER_DIVIDER;
Serial.print("Bat Voltage: ");
Serial.println(batLCB);
//digitalWrite(POWER_PIN,LOW);

Serial.println("Test done");
Serial.flush();
startLCB();
pinMode(MCPPOWER_PIN, OUTPUT);
pinMode(A0, OUTPUT);
pinMode(A1, OUTPUT);
pinMode(A2, OUTPUT);
pinMode(A3, OUTPUT);

}


void loop() {
digitalWrite(MCPPOWER_PIN, HIGH);
for (uint8_t ch = 0; ch < 16; ch++) {
digitalWrite(A0, ch & 0x8);
digitalWrite(A1, ch & 0x4);
digitalWrite(A3, ch & 0x2);
digitalWrite(A2, ch & 0x1);
delay(1);
mcp342x.runADC(0);
delay(mcp342x.getADCTime());
span = mcp342x.getData();
float strom = span / PRERESISTOR;
mcp342x.runADC(1);
delay(mcp342x.getADCTime());
span = mcp342x.getData();
Serial.print(span/strom/1000);
Serial.print(" ");
}
digitalWrite(MCPPOWER_PIN, LOW);
Serial.println();


}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void measure() {
digitalWrite(MCPPOWER_PIN, HIGH);
delayLogger(20);
for (uint8_t ch = 0; ch < 16; ch++) {
digitalWrite(A1, ch & 0x8);
digitalWrite(A0, ch & 0x4);
digitalWrite(A0, ch & 0x8);
digitalWrite(A1, ch & 0x4);
digitalWrite(A3, ch & 0x2);
digitalWrite(A2, ch & 0x1);
delayLogger(10);
Expand Down
Loading

0 comments on commit c2ebe05

Please sign in to comment.