Overclockers Australia Forums

OCAU News - Wiki - QuickLinks - Pix - Sponsors  

Go Back   Overclockers Australia Forums > Specific Hardware Topics > Electronics & Electrics

Notices


Sign up for a free OCAU account and this ad will go away!
Search our forums with Google:
Reply
 
Thread Tools
Old 12th March 2017, 11:50 AM   #181
pantner
Member
 
Join Date: Aug 2004
Location: Perth, WA
Posts: 2,095
Default

Quote:
Originally Posted by rainwulf View Post
use a watchdog timer.
I don't think that's what I want. From what I can see that can potentially reset the Arduino at any time (ie, whenever there is a serious issue).

That means it may happen while I am using the sound system it is controlling and it will reset everything to defaults.
__________________
Intel i7 860, Gigabyte PA55-UD5, 2x4GB DDR3, 300GB Velociraptor, 2x2TB Seagate SATA in RAID 0, NVIDIA GTX580, Pioneer DVD burner, Silverstone OP850W, ASUS 23" LCD, Acer 23" LCD, Microsoft X6, Microsoft Intellimouse, Noctua NH-D14
pantner is offline   Reply With Quote

Join OCAU to remove this ad!
Old 12th March 2017, 4:57 PM   #182
rainwulf
Member
 
Join Date: Jan 2002
Location: bris.qld.aus
Posts: 3,879
Default

Quote:
Originally Posted by pantner View Post
I don't think that's what I want. From what I can see that can potentially reset the Arduino at any time (ie, whenever there is a serious issue).

That means it may happen while I am using the sound system it is controlling and it will reset everything to defaults.
Have your program write its settings to eeprom.
Its actually really easy, i can post some code.


Quote:
/************************************************** *****************************/

#include <EEPROM.h>

byte eePROM[60]; // data to read/write from eeprom. in this case im storing 60 possible values.

/********
start of code
****/


/************************************************** *****************************/
void saveEEprom(void)
{ // saves settings to eeprom


for (byte i = 0; i < 59; i++) EEPROM.write(i, eePROM[i]);

EEPROM.write(60, 11); // write the magic number. Means it resets if a new device is used.
EEPROM.write(61, 00);
EEPROM.write(62, 02);
}

/************************************************** *****************************/
void getEEprom( void )
{ // get info from eeprom, if its not there, use a default set of vars.


for (byte i = 0; i < 59 ; i++) eePROM[i] = EEPROM.read(i);

// put in sanity checks on the EEPROM data JUST IN CASE.

if ((EEPROM.read(60) != 11) || (EEPROM.read(61) != 00) || (EEPROM.read(62) != 02)) // check to see if the pulled back data contains the magic number.
{ // nope. put in defaults.
// must be a new device
// set your various defaults in here.

// ok go and save them now, and write the magic number.
saveEEprom();
}
}
What you do then is have a set of defines that point to various areas into that array.
In my case i was using them to store information on a process control project.
#define EE_BUTTONS 0
#define EE_RESIZE 1
#define EE_OFFR 2
#define EE_OFFG 3
#define EE_OFFB 4
#define EE_ONR 5
#define EE_ONG 6
#define EE_ONB 7
#define EE_PIN1 8
#define EE_PIN2 9
#define EE_PIN3 10
#define EE_PIN4 11
#define EE_ID1 12
#define EE_ID2 13


so when my coded needed what the eeprom had stored instead of reading it on the spot i just use:
v1=eePROM[EE_ID1];
v2=eePROM[EE_ID2];

If that number changed anywhere else in the code, it would change here too, and on user input, it just goes to "save eeprom" again and writes the entries back to flash.
i should probably put in code to not bother writing if the number hasn't changed, but that's pretty easy.

So you end up with a global shared array thats persistent across resets, and even across new code uploads. If you programmed a new arduino, the code catches that the magic number isn't there, and then sets a set of default values.
__________________
derp

Last edited by rainwulf; 12th March 2017 at 5:12 PM.
rainwulf is offline   Reply With Quote
Old 12th March 2017, 4:58 PM   #183
rainwulf
Member
 
Join Date: Jan 2002
Location: bris.qld.aus
Posts: 3,879
Default

Quote:
Originally Posted by PabloEscobar View Post
Remember the thread title .

Are you talking about a hardware WDT? or using the soft one built in?

I'm a rank beginner at this stuff, so while I can google watchdog timer, I've got NFI which one will be applicable to my situation.

You can get a little hardware one that just ties to the reset line and an output pin.

You just hit the pin now and then to reset the timer. That way if your code locks up, the timer resets the arduino.
__________________
derp
rainwulf is offline   Reply With Quote
Old 12th March 2017, 6:09 PM   #184
pantner
Member
 
Join Date: Aug 2004
Location: Perth, WA
Posts: 2,095
Default

Quote:
Originally Posted by rainwulf View Post
Have your program write its settings to eeprom.
Its actually really easy, i can post some code.




What you do then is have a set of defines that point to various areas into that array.
In my case i was using them to store information on a process control project.
#define EE_BUTTONS 0
#define EE_RESIZE 1
#define EE_OFFR 2
#define EE_OFFG 3
#define EE_OFFB 4
#define EE_ONR 5
#define EE_ONG 6
#define EE_ONB 7
#define EE_PIN1 8
#define EE_PIN2 9
#define EE_PIN3 10
#define EE_PIN4 11
#define EE_ID1 12
#define EE_ID2 13


so when my coded needed what the eeprom had stored instead of reading it on the spot i just use:
v1=eePROM[EE_ID1];
v2=eePROM[EE_ID2];

If that number changed anywhere else in the code, it would change here too, and on user input, it just goes to "save eeprom" again and writes the entries back to flash.
i should probably put in code to not bother writing if the number hasn't changed, but that's pretty easy.

So you end up with a global shared array thats persistent across resets, and even across new code uploads. If you programmed a new arduino, the code catches that the magic number isn't there, and then sets a set of default values.
Ok thanks, will look into that
__________________
Intel i7 860, Gigabyte PA55-UD5, 2x4GB DDR3, 300GB Velociraptor, 2x2TB Seagate SATA in RAID 0, NVIDIA GTX580, Pioneer DVD burner, Silverstone OP850W, ASUS 23" LCD, Acer 23" LCD, Microsoft X6, Microsoft Intellimouse, Noctua NH-D14
pantner is offline   Reply With Quote
Old 13th March 2017, 4:45 PM   #185
rainwulf
Member
 
Join Date: Jan 2002
Location: bris.qld.aus
Posts: 3,879
Default

Quote:
Originally Posted by pantner View Post
Ok thanks, will look into that
Just try to avoid writing to eeprom until a value is changed, it doesnt last very long when you continuously write to it.
__________________
derp
rainwulf is offline   Reply With Quote
Old 14th March 2017, 9:37 PM   #186
azzachaz
Member
 
azzachaz's Avatar
 
Join Date: Nov 2003
Location: Canberra
Posts: 1,392
Default

Received a DHT Shield in the mail so had a play hooking it up.

http://www.esp8266learning.com/wemos...p#codesyntax_3

Then I got it to Tweet the temp:

https://twitter.com/AppsiumAaron

Using 'shields' is pretty cool. Makes things easy to plug together. I simply plugged this shield onto the D1 mini (ESP8266) and a lipo battery shield and the thing will tweet the temp from anywhere there is wifi.
__________________
Quote:
Originally Posted by phoenix: I got pissed off after 30 mins of irresponsive controls and mindnumbingly stupid gameplay, threw the NES back in the corner and went to play CS.
Originally posted by spectral: Times change. Pity "old rev heads" don't and will maintain to their grave that "hi tech turbo whiz bang computer car" are bad
Originally posted by .Net Developer: I could check it in, but it's gonna look like shit.
azzachaz is offline   Reply With Quote
Old 15th March 2017, 8:20 AM   #187
PabloEscobar
Member
 
Join Date: Jan 2008
Posts: 8,898
Default

Quote:
Originally Posted by azzachaz View Post
Received a DHT Shield in the mail so had a play hooking it up.

http://www.esp8266learning.com/wemos...p#codesyntax_3

Then I got it to Tweet the temp:

https://twitter.com/AppsiumAaron

Using 'shields' is pretty cool. Makes things easy to plug together. I simply plugged this shield onto the D1 mini (ESP8266) and a lipo battery shield and the thing will tweet the temp from anywhere there is wifi.
30 Degrees on a Canberra Morning... How much is your heating Bill .

Any ideas on battery life (or even how you would measure it?) Can you hook up the battery to one of the pins, and measure voltage drop over time or something similar to give you somewhat of an idea as to how long a battery will last.

I'm currently powering a temp sender from a 4000mAh phone battery pack (USB power pack thingy) but I've got no idea how long (or short) it will last.
PabloEscobar is offline   Reply With Quote
Old 15th March 2017, 9:49 AM   #188
azzachaz
Member
 
azzachaz's Avatar
 
Join Date: Nov 2003
Location: Canberra
Posts: 1,392
Default

Yeah, the house is pretty warm atm. The heater hasn't been on since last year.

I'm powering it from a tiny '380mAh' lipo from Aliexpress.
It went for about 8 hours Tweeting every half hour. I haven't done any 'optimization' of the code to reduce battery usage.

I simply sleep the ESP8266 between Tweets and that might be a Very Badtm thing to do.
__________________
Quote:
Originally Posted by phoenix: I got pissed off after 30 mins of irresponsive controls and mindnumbingly stupid gameplay, threw the NES back in the corner and went to play CS.
Originally posted by spectral: Times change. Pity "old rev heads" don't and will maintain to their grave that "hi tech turbo whiz bang computer car" are bad
Originally posted by .Net Developer: I could check it in, but it's gonna look like shit.
azzachaz is offline   Reply With Quote
Old 15th March 2017, 7:21 PM   #189
rainwulf
Member
 
Join Date: Jan 2002
Location: bris.qld.aus
Posts: 3,879
Default

Quote:
Originally Posted by azzachaz View Post
Yeah, the house is pretty warm atm. The heater hasn't been on since last year.

I'm powering it from a tiny '380mAh' lipo from Aliexpress.
It went for about 8 hours Tweeting every half hour. I haven't done any 'optimization' of the code to reduce battery usage.

I simply sleep the ESP8266 between Tweets and that might be a Very Badtm thing to do.
Apart from actually stopping the cpu sleep is the next best thing.

Most of the power usage is in wifi though, not cpu.
__________________
derp
rainwulf is offline   Reply With Quote
Old 20th March 2017, 12:28 PM   #190
azzachaz
Member
 
azzachaz's Avatar
 
Join Date: Nov 2003
Location: Canberra
Posts: 1,392
Default

Did a 'Arduino 101' circuit and got a small OLED screen displaying temp and humidity information via a DHT11 temp sensor.


Click to view full size!


Was pretty easy using a Nano board.

I've had a bit of trouble a couple of times now getting the I2C connections to work with ESP8266 type development boards. They aren't always consistently the same pins by default and I've given up a couple of times now.
__________________
Quote:
Originally Posted by phoenix: I got pissed off after 30 mins of irresponsive controls and mindnumbingly stupid gameplay, threw the NES back in the corner and went to play CS.
Originally posted by spectral: Times change. Pity "old rev heads" don't and will maintain to their grave that "hi tech turbo whiz bang computer car" are bad
Originally posted by .Net Developer: I could check it in, but it's gonna look like shit.
azzachaz is offline   Reply With Quote
Old 21st March 2017, 7:27 PM   #191
rainwulf
Member
 
Join Date: Jan 2002
Location: bris.qld.aus
Posts: 3,879
Default

Be careful with those OLED displays. They actually can suffer burn in.

Either do it with a nokia LCD or something similar, or perhaps move it around on the screen.

One i saw used a small piezo sensor as a "knock" sensor. It was mounted behind the OLED but on it. When you wanted to see the screen, you just knocked or tapped the screen like you would do with an old analog gauge hahaha

It would appear for 30 seconds then go black again.
__________________
derp
rainwulf is offline   Reply With Quote
Old 24th March 2017, 12:14 PM   #192
azzachaz
Member
 
azzachaz's Avatar
 
Join Date: Nov 2003
Location: Canberra
Posts: 1,392
Default

Has anyone (or could anyone try?) managed to get a Wemos D1 Mini (clone) to communicate with anything over I2C?

I just don't seem to be able to.
Not sure if there are default pins or I need to set them manually.
Following online examples doesn't seem to work for me.

Tried with OLED, Temp sensor, RFID scanner.

These all work straight away with other arduino boards. Just the ESP8266 based boards wont work for me.
__________________
Quote:
Originally Posted by phoenix: I got pissed off after 30 mins of irresponsive controls and mindnumbingly stupid gameplay, threw the NES back in the corner and went to play CS.
Originally posted by spectral: Times change. Pity "old rev heads" don't and will maintain to their grave that "hi tech turbo whiz bang computer car" are bad
Originally posted by .Net Developer: I could check it in, but it's gonna look like shit.
azzachaz is offline   Reply With Quote
Old 24th March 2017, 12:58 PM   #193
pantner
Member
 
Join Date: Aug 2004
Location: Perth, WA
Posts: 2,095
Default

Quote:
Originally Posted by azzachaz View Post
Has anyone (or could anyone try?) managed to get a Wemos D1 Mini (clone) to communicate with anything over I2C?

I just don't seem to be able to.
Not sure if there are default pins or I need to set them manually.
Following online examples doesn't seem to work for me.

Tried with OLED, Temp sensor, RFID scanner.

These all work straight away with other arduino boards. Just the ESP8266 based boards wont work for me.
have a look here

http://www.esp8266.com/viewtopic.php?f=13&t=10374

The tricky thing is the pin labels on the board don't match the hardware IDs!
__________________
Intel i7 860, Gigabyte PA55-UD5, 2x4GB DDR3, 300GB Velociraptor, 2x2TB Seagate SATA in RAID 0, NVIDIA GTX580, Pioneer DVD burner, Silverstone OP850W, ASUS 23" LCD, Acer 23" LCD, Microsoft X6, Microsoft Intellimouse, Noctua NH-D14
pantner is offline   Reply With Quote
Reply

Bookmarks

Sign up for a free OCAU account and this ad will go away!

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +10. The time now is 3:26 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
OCAU is not responsible for the content of individual messages posted by others.
Other content copyright Overclockers Australia.
OCAU is hosted by Micron21!