johnmccombs / arduino-libraries Goto Github PK
View Code? Open in Web Editor NEWMy Arduino libraries folder
My Arduino libraries folder
Hi,
Just discovered your Arduino Libraries and thanks for all your work. I am new to arduino so if this is a newbie question please excuse me. I have a project where I need to set an alarm and I am using Alarm.timerRepeat(60, SendEmail); which should trigger every 60 seconds but it will trigger four to five times in a row and then trigger again in 60 seconds again 4-5 times. Below is the sketch that I am using. The sketch is not fully done but I was testing the library to see if it would suit my needs. Thanks again.
/*
Holding Tank Alarm v0.01
Reads an analog input on pin 0, converts it to voltage. If voltage is above 0 volts it sends a text that the
tank needs to be pumped. Connects wirelessly to WiFi in the house. If connection is lost program will continue to try to reconnect to WiFi and sends a text that it has reestablished connection. Program checks RTC on startup and once a month afterwards to set the time.
*/
// add libraries
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
setTime(22,00,0,1,30,15);
SendEmail();
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
//display time
digitalClockDisplay();
// wait one second between clock display
Alarm.delay(1000);
// timer for every 60 seconds
Alarm.timerRepeat(60, SendEmail);
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void SendEmail()
{
Serial.println("Email sent");
}
I try to compile your code for esp8266 that is a 32bit cpu and i notice that you assume 16bit int size,
better leave to compiler these work!
here a possible solution
if (x&0x2000){
x= x-0b11111111111111-1;
//x|=0xc000; // set full 2 complement for neg values
}
The library produces two warnings with Arduino UNO in Arduino IDE 1.8.19
`C:\Daten\myrepository\Arduino\libraries\PString/PString.h:56:10: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
inline const size_t length()
^~~~~
C:\Daten\myrepository\Arduino\libraries\PString/PString.h:60:10: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
inline const size_t capacity()
^~~~~
`
As code you can use the example test_pstring
According https://stackoverflow.com/questions/1134237/pedantic-gcc-warning-type-qualifiers-on-function-return-type a return type should not be const as the return value can be dynamic. At least for length() this makes sense.
Issue could be solved when keyword const gets removed.
Hi johnmccombs,
I am pleased that your coding is helping, and I'm using it for my project, I am using your Time library for my Arduino POV clock but there's a problem I'm facing in the DataStrings.cpp, as I am still learning in Arduino and I'd like to know what I've done wrong, and if there's any suggestion to solve it. And here's the compilation error I'm getting, i pasted here part of it, but it continues the same pattern of error:
In file included from /Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:10:0:
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:18:18: error: variable 'monthStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr1[] PROGMEM = "January";
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:19:18: error: variable 'monthStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthStr2[] PROGMEM = "February";
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:36:26: error: variable 'monthShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char monthShortNames_P[] PROGMEM = {"ErrJanFebMarAprMayJunJulAugSepOctNovDec"};
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:38:16: error: variable 'dayStr0' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr0[] PROGMEM = "Err";
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:39:16: error: variable 'dayStr1' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr1[] PROGMEM = "Sunday";
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:40:16: error: variable 'dayStr2' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr2[] PROGMEM = "Monday";
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:45:16: error: variable 'dayStr7' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayStr7[] PROGMEM = "Saturday";
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:47:20: error: variable 'dayNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
PGM_P dayNames_P[] PROGMEM ={dayStr0,dayStr1,dayStr2,dayStr3,dayStr4,dayStr5,dayStr6,dayStr7};
^
/Users/S_Pineapple/Documents/Arduino/libraries/Time/DateStrings.cpp:48:24: error: variable 'dayShortNames_P' must be const in order to be put into read-only section by means of 'attribute((progmem))'
char dayShortNames_P[] PROGMEM = "ErrSunMonTueWedThrFriSat";
^
exit status 1
Error compiling.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.