Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lowen SoDium
Jun 5, 2003

Highen Fiber
Clapping Larry

ultrabay2000 posted:

Has someone seen something like a ESP8266 with a battery backed RTC? Is that a thing?

I saw a $50 Arduino IOT type device but I was hoping for something smaller / cheaper.

Splode posted:

I used the esp8266 to pull time from time servers rather than use an RTC, but that might not be viable for whatever you're doing.

That what I did for my project. I have it check the time once per hour since my needs don't need to be real-time accurate.


evil_bunnY posted:

Any particular reason you're sticking to the older 8266? If I wanted something with radios and an RTC I'd probably get a $20 esp32 feather and a $13 TC-RTC wing and call it good.

You can get 8266's real cheap on amazon and aliexpress. Like $3-4 each. But then again, I have had to replace 2 seperate ones I used in about 18 months.

Adbot
ADBOT LOVES YOU

huhu
Feb 24, 2006
Anyone have any recommendations for resources for learning MicroPython (with the ESP2866)? I see a few books on Amazon but none look promising and I can't really find good Youtube videos or other courses online.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
Learn Python, the core language is the same and you can do it with Python on your desktop. Then when you're comfortable with the basics of the language (functions, loops, etc.) just read the MicroPython docs to pick up the hardware API. This is a good resource for learning Python: http://docs.python-guide.org/en/latest/intro/learning/

huhu
Feb 24, 2006

mod sassinator posted:

Learn Python, the core language is the same and you can do it with Python on your desktop. Then when you're comfortable with the basics of the language (functions, loops, etc.) just read the MicroPython docs to pick up the hardware API. This is a good resource for learning Python: http://docs.python-guide.org/en/latest/intro/learning/

Sorry, I should clarify, I'm a Python developer by day. I was looking for resources geared towards people with a background in microcontrollers and Python already.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
Yeah, you've got all the skills then. Read the API docs and you're set: http://docs.micropython.org/en/latest/esp8266/ If you want to learn about hardware, microcontrollers, etc. in general then that's kind of tangential--check out the typical recommendations like Make: Electronics, Getting Started with Arduino, etc. Even if it isn't using MicroPython the basic ideas of digital logic, analog inputs, PWM, etc. will all apply and you can just consult the API docs to see how MicroPython exposes it on your board of choice. If you get really deep into MicroPython it will help to start getting familiar with C extensions to Python too, as MicroPython is really just a Python C extension wrapper around a board's HAL/hardware access layer--you'll quickly find you might need to mix C and Python code to access hardware at the lowest level, get the most speed, save memory, etc.

Splode
Jun 18, 2013

put some clothes on you little freak
It's worth noting once you are messing with registers and peripherals you may have more luck asking questions in the embedded programming microthread or the electronics thread. Feel free to ask here too though.

Sorry about no links, phone posting

While I'm here, I use a lot of Arduino Dues at work because it's not my money lol.
That said, they're physically huge. Does anyone have any recommendations for Arduino compatible boards with shitloads of IO in a smaller package? A nice fast arm processor is nice too but pretty unnecessary.

Splode fucked around with this message at 21:46 on Mar 27, 2018

Sagebrush
Feb 26, 2012

The Teensy 3.2 or 3.6 are good options.

TheresaJayne
Jul 1, 2011
I have some tinyATs that i would like to have with some form of Dongle type functionality.

The idea is that you plug into a PC where some software that knows the public key of a remote device can then use a public key of the dongle to encrypt the public remote device key onto the dongle.

The remote device also an arduino, would say control some hardware and would lock out the controls unless a valid dongle is plugged into the usb port

Oh! and the dongle can also have a time lock system so the hardware the dongle is plugged into only unlocks at some predetermined time as set in the dongle in advance (the dongle doesnt need to contain an RTC just the period of time that the dongle will work)

TL;DR;
I want to be able to unlock one arduino by plugging in another one containing an encrypted key set by a computer or maybe time locked as well.

The idea is for a building door system where some people can only access at certain times and others all the time but getting away from the NFC solutions

Splode
Jun 18, 2013

put some clothes on you little freak

Sagebrush posted:

The Teensy 3.2 or 3.6 are good options.

Perfect thanks, I'd forgotten about teensy

evil_bunnY
Apr 2, 2003

TheresaJayne posted:

I have some tinyATs that i would like to have with some form of Dongle type functionality.

The idea is that you plug into a PC where some software that knows the public key of a remote device can then use a public key of the dongle to encrypt the public remote device key onto the dongle.

The remote device also an arduino, would say control some hardware and would lock out the controls unless a valid dongle is plugged into the usb port

Oh! and the dongle can also have a time lock system so the hardware the dongle is plugged into only unlocks at some predetermined time as set in the dongle in advance (the dongle doesnt need to contain an RTC just the period of time that the dongle will work)

TL;DR;
I want to be able to unlock one arduino by plugging in another one containing an encrypted key set by a computer or maybe time locked as well.

The idea is for a building door system where some people can only access at certain times and others all the time but getting away from the NFC solutions
secfuck: don't roll your own.

Hadlock
Nov 9, 2004

evil_bunnY posted:

secfuck: don't roll your own.

Solid advice

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:
So I bought the wrong relays... I am using a NodeMcu with the blynk app and want to control a relay. The relay I bought needs 5V and the board puts our 3.3V what options have I got? (I tried as "some" work but not this one)

evil_bunnY
Apr 2, 2003

Replace the board or the relays, whatever is cheaper.

thegasman2000
Feb 12, 2005
Update my TFLC log? BOLLOCKS!
/
:backtowork:

evil_bunnY posted:

Replace the board or the relays, whatever is cheaper.

Yeah I was hoping to avoid that. Shipping from china is super slow at the price I want to pay for these.

evil_bunnY
Apr 2, 2003

Then cludge something with mosfets!

Hadlock
Nov 9, 2004

thegasman2000 posted:

Yeah I was hoping to avoid that. Shipping from china is super slow at the price I want to pay for these.

My experience is that if you order from Hong Kong, rather than mainland China, shipping time is usually under 9 days, often 4 or 5, even to Texas.

Shipping from China, yeah I've seen anywhere from 16 days to 4 months. Usually there's some guy within a three state radius selling the same stuff for $0.50 more ea that ships same day if you shop around or filter by "ships from us". Most anything that has an Arduino library, some US nerd will have in stock.

Splode
Jun 18, 2013

put some clothes on you little freak

evil_bunnY posted:

Then cludge something with mosfets!

If you have a 5V rail, this is probably the easiest solution.

TheresaJayne
Jul 1, 2011

evil_bunnY posted:

secfuck: don't roll your own.

i am not rolling my own encryption i will use std aes keys but i was wanting to have a small micro USB stick that can be programmed and read to access the encryption.

ie I plug into the PC, and using the PC sw i use the other device serial number as the registration code.
Then you can unplug the stick and then plug into the other device which checks the code and if the serial number matches it activates.

Aurium
Oct 10, 2010

thegasman2000 posted:

So I bought the wrong relays... I am using a NodeMcu with the blynk app and want to control a relay. The relay I bought needs 5V and the board puts our 3.3V what options have I got? (I tried as "some" work but not this one)

Do you know what's not working? It could either possibly be a logic thing, which is unlikely, as 3.3v is within logic high for almost everything 5v, and most relay board inputs are optoisolator driven and will often work even lower.

It's more likely that the problem is that 3.3v doesn't provide enough current though the coil. In that case you should power the relay board with something higher, but it will probably still trigger on the logic voltages out of your node mcu.

TheresaJayne
Jul 1, 2011

Aurium posted:

Do you know what's not working? It could either possibly be a logic thing, which is unlikely, as 3.3v is within logic high for almost everything 5v, and most relay board inputs are optoisolator driven and will often work even lower.

It's more likely that the problem is that 3.3v doesn't provide enough current though the coil. In that case you should power the relay board with something higher, but it will probably still trigger on the logic voltages out of your node mcu.

you could always have a seperate 5v power feed for the relay and trigger it with a transistor which could work on as low as 1v or less

edmund745
Jun 5, 2010

thegasman2000 posted:

So I bought the wrong relays... I am using a NodeMcu with the blynk app and want to control a relay. The relay I bought needs 5V and the board puts our 3.3V what options have I got? (I tried as "some" work but not this one)

There is transistors you could use.
The "real" way this is done is by using a chip called a "gate driver"... but a regular old transistor or mosfet may cost less than that.

Aurium
Oct 10, 2010

edmund745 posted:

There is transistors you could use.
The "real" way this is done is by using a chip called a "gate driver"... but a regular old transistor or mosfet may cost less than that.

A gate driver is for driving mosfet gates. (Or the occasional igbt driver)

They're optimized for driving highly capacitive loads, at non-logic levels. (Often 10-15v). They'll also frequently have an onboard charge pump (very low current voltage booster) to generate that voltage for you.

I mean you could use it for generic level shifting, I suppose. People would look at you oddly.

If what you want is an ic to communicate between different logic levels, you're looking for a level shifter, or translator or convertor or a suitable buffer.

That said, as I noted earlier, depending on the reason why it doesn't work, any level shifting could either not help at all, or be unnecessary.

rawrr
Jul 28, 2007
I'm about 80% done with an Arduino project, but I'd like to port it over to ESP32 for the BLE and maybe wifi.

The ESP32 doesn't have enough I/0 pins and I don't really want to deal with sensor library compatibility issues, so I'm thinking of hooking up the sensors (and relay control signals for the heater etc) to an Arduino, and link it to a ESP32 using i2c. The ESP32 would run the user interface (button inputs, displays, iot whatever) and just query the arduino for sensor inputs to update the displays, and send it commands to turn on the pump etc.

Is this dumb? Is there a better, simpler, and/or more robust interface/protocol that I should be using like serial?

Sagebrush
Feb 26, 2012

Can you just use like an I2C port expander or something?

rawrr
Jul 28, 2007
I could for the outputs that control the various relays, but the main reason I want to use an Arduino is because I have a bunch of sensors I need to interface with, each with their own protocols (one sends its output by varying its duty cycle, for example). So for me it seems like I can kill two birds with one stone if I just used an Arduino to interface with all the sensors.

Splode
Jun 18, 2013

put some clothes on you little freak
Can you not use the arduino libraries with the ESP32? I've done arduino projects with an ESP8266 and it was painless.

rawrr
Jul 28, 2007
I think you can, but the libraries I'm using don't have 100% compatibility because some make use of timers and stuff that I have no idea about. So between that and not having enough i/o pins, I was thinking it'd be easier and faster to have arduino deal with the sensor interfacing. I just don't know what the downsides of doing that are; I don't mind if it's more expensive because I need to buy both microcontrollers.

Splode
Jun 18, 2013

put some clothes on you little freak
It's not that big a downside honestly. It costs more and requires more space but it's easier than sorting out interrupts or writing a sequencer or something. I would personally use UART to have the two devices communicate, but i2c and SPI will also work fine.
My approach would be to set up the arduino as a slave, so your ESP can send it a command and recieve back the relevant data from whichever sensor it asked for. It wouldn't be very difficult, and it'll be really easy to debug them seperately.

politicorific
Sep 15, 2007
Project Question!
Keywords: ESP8266, Deepsleep, Flip-flop, MQTT

Six months ago I bought a small color changing lamp for $1 in Korea. It has a single 7 color fading/shifting LED inside powered by 3 AAA batteries. I thought, hey I've got a bunch of ESP8266-01 modules which I could use to turn it into an IOT lamp - a good chance to learn IOT stuff. I'd like the lamp to turn on when my phone was detected on my home wi-fi network, turn off when it wasn't on the network, during daylight hours, and shut off after 3-4 hours around midnight to 2 am. This is proving to be more challenging than I expected.

The ESP8266 consumes too power to be constantly running off AAA batteries. I measured about ~75 mA while idle - the color changing LED's consumption is much less. It's obvious I need to put the ES8266 to sleep. I figure I'd make an MQTT server do the heavy lifting and make the ESP a 'dumb' device. The programming is the easy part. Python can parse my computer's ARP table and Mosquitto can handle topic creation and the publishing of messages. Each time the ESP-8266 wakes up, it subscribes to the MQTT topic, publish a "Ready for job" message to the topic, wait for the reply, and either turn on the light or not, then go to deep sleep. After sundown, I could maybe make it wake up every 20 minutes to check for my phone. I've read the ESP8266 can deep sleep for a maxium of ~71 minutes (32 bits / 2 billion microseconds?) - I could have the server tell the ESP to go to sleep longer by manipulating a timer value in the flash memory, and have the ESP check the status each boot, 'short-cutting' the power hungry Wi-Fi connection routing, but /effort/.

Problem #1: The big question is how to maintain the GPIO 'on'/high state while the ESP8266 is sleeping. My first thought was to use a flip-flop. However, I just read the ESP8266 outputs a few micro-amps of voltage during DeepSleep.

I settled on a 555 to act as the flip flop. The ESP8266-01's GPIO2 connects to pin 4 of the 555 (reset) and GPIO0 to pin 2 (set). I have a 0.01 micro-farad capacitor on pin 5 and ground of the 555. I also soldered a wire from the ESP8266's SoC GPIO16 pin to the reset pin and tied the CH_PD to VCC. I put together a small circuit on some perf board since my breadboard seemed to trigger the 555 inputs. I got the flip flop working with tactile switches. I used a 2 x 4 Dupont pin female header for the ESP8266 and cut a dip socket for the 555.

For ESP testing, I used this sketch:
https://randomnerdtutorials.com/esp8266-web-server-with-arduino-ide/
After I set the output high, I physically removed the ESP8266 from the circuit and the LED stayed lit. Seemed like I was on track

Next, I tried adding a manual 'deepSleep' button to the web interface, but the LED turns off as soon as the device goes to sleep!
(I used a dummy GPIO and copied the code due to laziness)

code:
            // Makes the ESP sleep
            if (header.indexOf("GET /3/on") >= 0) {
              Serial.println("GPIO 3 on");
              output3State = "on";
              delay(100);
              ESP.deepSleep(1e6);
What am I doing wrong?

Problem #2: The 7-color fading LED seems to need a minimum of 3.0 volts to successfully cycle the entire color range.I can tell the brightness fades when the batteries get low. I can get between 3.0 and 3.6 volts from the AAA batteries (depends on how abused they are with start-ups), but 555 output is roughly 2.2 volts. This seems low. I thought I could use a transistor ULN2003a on a breadboard, but that drops the voltage by about 0.7 volts. If I connect the 555 output to the Darlington transistor, I get about 1.5 volts - a red LED won't even turn on.

Confirm/Deny: A MOSFET should be able to switch on the LED from the 3.6 - 3.0 volt battery power without any voltage drop. Can anyone recommend a suitable part?

Splode
Jun 18, 2013

put some clothes on you little freak
I've used LEDs with forward voltage drops as high as 3.4V, you may need to reconsider your power system.

As for the turning off problem, measure the pin assigned to reset with a multimeter (or better yet an oscilloscope if you have one) and see what it's doing. That should give you an idea about how to fix it.

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


politicorific posted:

I settled on a 555 to act as the flip flop. The ESP8266-01's GPIO2 connects to pin 4 of the 555 (reset) and GPIO0 to pin 2 (set). I have a 0.01 micro-farad capacitor on pin 5 and ground of the 555. I also soldered a wire from the ESP8266's SoC GPIO16 pin to the reset pin and tied the CH_PD to VCC. I put together a small circuit on some perf board since my breadboard seemed to trigger the 555 inputs. I got the flip flop working with tactile switches. I used a 2 x 4 Dupont pin female header for the ESP8266 and cut a dip socket for the 555.

This seems strange; I can't get this 555 circuit to work for me.

I googled "555 toggle flip flop" and with a 555 and a NPN transistor and some passives, I got a toggle flip flop to work. Basically, you get your 555 set up in bistable mode, then use the transistor to hook your single GPIO pin to the trigger of the 555. Every time you send a "high" pulse, the light toggles state. When no pulse is sent, or the input is floating (chip in sleep) then the lamp remains doing what it was doing.

Only registered members can see post attachments!

politicorific
Sep 15, 2007

babyeatingpsychopath posted:

This seems strange; I can't get this 555 circuit to work for me.

I googled "555 toggle flip flop" and with a 555 and a NPN transistor and some passives, I got a toggle flip flop to work.


I’ll create a schematic and attach it later.
I got the idea of using a set/reset after watching Ben Eater’s videos on his very cool 8 bit breadboard computer.
https://www.youtube.com/watch?v=9PPrrSyubG0

I don’t have the link to what i was looking at- I’ve been looking at a lot of 555 circuits lately(denouncing, oscillators)


Problem #2 - I got some fdn337ns to play with, they should do the voltage switching I need.

One Legged Ninja
Sep 19, 2007
Feared by shoe salesmen. Defeated by chest-high walls.
Fun Shoe

politicorific posted:

(denouncing, oscillators)

"Let it be known that this 555 is hereby declared a heretic of the Church!"

gonadic io
Feb 16, 2011

>>=
I previously had my arduino talking to a digital compass/gyro (MPU-9250) using the example sketch

which gave readings like:


but now the chip is returning nothing but zero readings even on the exact same example sketch:

quote:

X-acceleration: 0.00 mg Y-acceleration: 0.00 mg Z-acceleration: 0.00 mg
X-gyro rate: 0.000 degrees/sec Y-gyro rate: 0.000 degrees/sec Z-gyro rate: 0.000 degrees/sec
X-mag field: 0.00 mG Y-mag field: 0.00 mG Z-mag field: 0.00 mG

As far as I can tell the I2C communication is still working, just BOTH of my compass boards (I have a spare too) at once suddenly decided to misbehave?

Even better one of them seems to be developing a bulge on the processor (hopefully it's visible):


I've emailed Mouser (where I bought them from) asking for a refund but I'm very confused by what is going on. It's a very hot weekend where I am but I checked and the chips are rated up to 130C! They've never been connected to anything other than my 3.3V mkrzero.

mod sassinator
Dec 13, 2006
I came here to Kick Ass and Chew Bubblegum,
and I'm All out of Ass
If you put a thermometer or briefly touch the chip is it hot? That could indicate a short somewhere that could be throwing everything off and destroying the chip. The soldering on those headers looks a little big and blobby too--make sure nothing is touching other pads. You might want to reflow all those joints and suck them up with a solder sucker or wick to redo them so they look like this: https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools Use just enough solder to get nice little curves around the pins that stick up.

gonadic io
Feb 16, 2011

>>=
I guess my lovely soldering is the common factor here, I'll give that a try thanks. At least waiting a few days for replacement parts will let me work out how to call the samd21 I2C peripheral from rust! Doing it via the arduino ide is all very well but pretty annoying when you're used to less terrible IDEs.

Mr. Bubbles
Jul 19, 2012
Anyone knowledgeable about RFM69 and radiohead library? I have a couple example scripts working but not sure how to transition the example to a data struct payload. Currently using Feather M0 with RFM69HCW as transmitter and Feather ESP8266 with RFM69HCW Featherwing. Would like to pass two variables (temp and humidity) from one controller to another.

The two scripts I'm using are:
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_RX/RadioHead69_RawDemo_RX.ino
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_TX/RadioHead69_RawDemo_TX.ino

Mr. Bubbles fucked around with this message at 16:57 on May 29, 2018

babyeatingpsychopath
Oct 28, 2000
Forum Veteran


Mr. Bubbles posted:

Anyone knowledgeable about RFM69 and radiohead library? I have a couple example scripts working but not sure how to transition the example to a data struct payload. Currently using Feather M0 with RFM69HCW as transmitter and Feather ESP8266 with RFM69HCW Featherwing. Would like to pass two variables (temp and humidity) from one controller to another.

The two scripts I'm using are:
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_RX/RadioHead69_RawDemo_RX.ino
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_TX/RadioHead69_RawDemo_TX.ino

On the sending end, instead of
C code:
char radiopacket[20]="some payload";
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
You'd have
C code:
union { 
	struct {int temp, int hum }; 
	uint_8t data[sizeof(int)*2];
	} radiopacket;
rf69.send((uint8_t *)radiopacket.data, sizeof(radiopacket));
rf69.waitPacketSent();
On the other end, you'd have an equivalent union/structure on the receive.
C code:
rf69.recv(buf,&len);
if(len == sizeof(radiopacket)) 
	memcpy(radiopacket.data,buf,sizeof(radiopacket));
printf("%d %d\n",radiopacket.temp,radiopacket.hum);
Bounds and error checking are left as a device for the user. This union/struct thing is pretty common in low-level networking.

Mr. Bubbles
Jul 19, 2012

babyeatingpsychopath posted:

On the sending end, instead of
C code:
char radiopacket[20]="some payload";
rf69.send((uint8_t *)radiopacket, strlen(radiopacket));
rf69.waitPacketSent();
You'd have
C code:
union { 
	struct {int temp, int hum }; 
	uint_8t data[sizeof(int)*2];
	} radiopacket;
rf69.send((uint8_t *)radiopacket.data, sizeof(radiopacket));
rf69.waitPacketSent();
On the other end, you'd have an equivalent union/structure on the receive.
C code:
rf69.recv(buf,&len);
if(len == sizeof(radiopacket)) 
	memcpy(radiopacket.data,buf,sizeof(radiopacket));
printf("%d %d\n",radiopacket.temp,radiopacket.hum);
Bounds and error checking are left as a device for the user. This union/struct thing is pretty common in low-level networking.

Got it working, thanks for the help!

Mr. Bubbles fucked around with this message at 22:41 on May 30, 2018

Adbot
ADBOT LOVES YOU

Cardiac
Aug 28, 2012

Mr. Bubbles posted:

Anyone knowledgeable about RFM69 and radiohead library? I have a couple example scripts working but not sure how to transition the example to a data struct payload. Currently using Feather M0 with RFM69HCW as transmitter and Feather ESP8266 with RFM69HCW Featherwing. Would like to pass two variables (temp and humidity) from one controller to another.

The two scripts I'm using are:
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_RX/RadioHead69_RawDemo_RX.ino
https://github.com/adafruit/RadioHead/blob/master/examples/feather/RadioHead69_RawDemo_TX/RadioHead69_RawDemo_TX.ino

You could also check out some Nexa/Proove Arduino protocols that does this.
I tested both the receiver and transmitter parts and both works nicely.
In my case it was mainly to interact with my tellstick duo.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply