-
Hello y'all,
I recently made a project, it's a watch powered by the MDBT42Q and a CR2032 coin cell, whch is 220 mah.
full details here: https://iamericmin.github.io/tm5.html
It's an updated version of a previous watch that also used an MDBT42Q and a smaller CR1225 cell, which is only 50 mah. The old watch lasted about two weeks, but mine can't go more than two days!The only culprit I can think of is the external crystal. I added a 32khz crystal with 22pf caps to the new watch, maybe that's why? The previous watch just tracked time with its internal crystal.
Also, the Espruino website says that MDBT42Q modules go to deep sleep automatically when proper conditions are met. So I'm really baffled here :'(
Any help would be greatly appreciated. Thanks!
-
@Gordon Oh my goodness thank you so much! It works like a charm :)
One question tho, what does "+" do before and after a variable? Since you wrote '+i+' and '+x+' when referencing to elements in the array segs[]. I've never seen that before in any language. -
Hi,
I'm trying to write a simple LED animation for a 7-segment display. It will light up a segment, then another one, then another one, until all are lit up, then dim a segment, then dim another one, etc. The code is (supposed to be) very simple. For reference, I'm using an MDBT42Q module with a 32khz crystal added on P0 and P1 with 22pf caps. I don't think it should affect my code.
var segs = [A, B, C, D, E, F]; // array of LED segments, each a variable for a pin for (int i=0; i<6; i++) { digitalWrite(segs[i], 1); // light up the first segment in segs[] digitalPulse(D30, 0, 100); // pulse unused pin for 100ms, this is just a simple delay } for (int x=5; x>=0; x--) { digitalWrite(segs[i], 0); digitalPulse(D30, 0, 100); }
and well, the code works as if the digitalPulse()es aren't even there. Everything happens very quickly so the LEDs just light up and off in a fraction of a second. I honestly have no idea why this isn't working as the other digitalPulses in the rest my code work just fine. I have other LED animations that use digitalPulse() in my code and those animations have no problem.
So I tried using setTimeout(). I believe it's like so, but I might be wrong:
for (var i = 0; i<6; i++) { setTimeout('digitalWrite(segs[i], 0)', 100); } for (var x = 5; x>=0; x--) { setTimeout('digitalWrite(segs[x], 1)', 100); }
this one doesn't work either. So I tried another method:
digitalWrite(A, 1); digitalPulse(D3, 0, 100); digitalWrite(B, 1); digitalPlulse(D3, 0, 100); digitalWrite(C, 1); digitalPulse(D3, 0, 100); . . .
And same results.
This has been driving me absolutely bonkers for the past few hours so any help would be greatly appreciated! -
-
Hi there,
I want to make a small robot that moves with two vibration motors on each side. I will remove the motors' eccentric weights and replace them with small wheels, so the vibration motors will essentially act like really small DC motors. I'm thinking of using an MDBT42Q. How do I connect the motors to the microcontroller? Should I just connect one wire to a signal and another to ground? Or are there passive components needed?Also, how long would my robot last? It will have two mini vibration motors, two green LEDs(on for about 5 minutes I think) and will be recieving commands OTA via bluetooth. It's all powered by a CR2032 battery.
Thanks!
-
Hi,
I just thought of this and I just want to see if it will work. I want to see if I can multi-boot a microcontroller, such as an ESP32 or STM32 chip from multiple flash chips. For example, I can have Espruino on one chip, Micropython in the other, Lua on the third, etc. I think it will be awesome but before I make it I want to see if it's possible. If it is, how hard would it be?
Thanks!
P.S. Massive congrats to Gordon for getting 658% of his funding goal for Bangle.JS as of November 24 2019! I can't wait for the new device and wish Gordon the best on his embedded endeavors.
-
Hi, I programmed my MDBT42Q module to make a small beep sound whenever I press or release a button. This is the code for my piezo sound effects:
function beep(f) { if (f===0) digitalWrite(spk,0); else analogWrite(spk, 0.5, { freq: f } ); } function buttonBoop(f) { beep(f); setTimeout(function() {digitalWrite(spk, 0);}, 50); }
pretty simple, right?
So I tried to put them into setWatch functions so that my wristwatch(the PCB that houses the MDBT42Q module) can make a small beep whenever a button is pressed. The two setwatches are for when the button is pressed and released. When the button is pressed, the watch displays the hour on its two 7-seg LEDs for as long as the button is held down. when the button is released, the watch displays the minutes for 300 milliseconds. Here is the code:
setWatch(function(e) { data(); // grabs date & time buttonBoop(650); // supposed to beep piezo at 650hz for 50 milliseconds while (digitalRead(select) != 1) { // the watch displays the hour display(1, hourFirstDigit); display(2, hourSecondDigit); } allClear(); // resets 7-segment displays }, select, {repeat: true, debounce: 50, edge: "falling"}); setWatch(function(e) { data(); // grabs date & time buttonBoop(950); // supposed to beep piezo at 950 hz for 50 milliseconds for (i = 0; i < 30; i++) { // watch displays the minutes display(1, minFirstDigit); display(2, minSecondDigit); } allClear(); // resets the 7 seg LEDs }, select, {repeat: true, debounce: 50, edge: "rising"}); }
the problem is, whenever I press/release the button, the piezo speaker beeps until the LEDs are cleared. That is, when the button is pressed, the piezo beeps at 650hz until I release it, and when the button is released, the piezo beeps at 950mhz for 300mhz - which is when the LEDs are cleared. Sorry if this sounds confusing for you, I can't find a way to word it well.
I only want the piezo to beep for 50 milliseconds, what is making it go for the entire setWatch() duration?
The strange thing is, when do a clearWatch() and run this instead...
setWatch(function(e) { buttonBoop(650); }, select, {repeat: true, debounce: 50, edge: "falling"}); setWatch(function(e) { buttonBoop(950); }, select, {repeat: true, debounce: 50, edge: "rising"});
the piezo behaves just fine. A short beep when the button is pressed, and another short beep when the button is released. It's the same setWatch() code but with all the LED/time related code removed. But I can't find anything with my LED/time code. Thought this would help.
This is the entire source code for my watch. The buggy part is near the end.
Thanks.
-
-
@Gordon Thanks for the idea, I don't have the skill or area on my circuit board to integrate a lipo charging circuit, so I might just have an off-the-shelf charging board in my charging dock/cable.
-
Hey @AkosLukacs, I have two multiplexed 7-segment LEDs and five more LEDs each with their own GPIO pin, all colored blue. All of them are tied to a 330 ohm resistor in series. The microcontroller I'm using operates on 3.3v logic so this might not be necessary, I just tossed the resistors in for safety. The LEDs are fairly visible during normal use, although not at their peak brightness. My circuit is a wristwatch, so I don't have the real estate for two AA batteries.
-
Hey @Gordon and @allObjects,
I just tried this out on a breadboard, and while it does work, my LEDs (multiplexed 7 segments) are very dim when powered by the coin cell only. Without the diode between the coin cell and the microcontroller the LEDs are nice and bright. I have 5 other LEDs each wired to an IO pin and they are slightly dimmer too. When powered by USB though they all light up perfectly.I bought 1N4007 diodes, the shop didn't have any schottky diodes. Will the LEDs be fine if I use a schottky diode? Thanks.
-
-
-
-
Hey what's up,
Will I hurt my MDBT42Q module by connecting a coin cell battery in parallel with a USB jack(or any other connector really, like a JST) for optional external power? Will it hurt the battery? I've attached a simple diagram to further clarify what I mean.The coin cell is a 3V CR1225 cell and the external power connector will be a similar 3.3v power source.
EDIT: the external power connector will also handle data transfer through the RX/TX lines.
-
Do you have access to a scope to look at the mic output? If so, what is the range? If not, a spec/datasheet?
@Robin I don't have a scope.
Do you want the uC to detect the clap (sampling the audio all time) or do you want the sleeping uC be woken up by an interrupt triggered by the microphone?
@maze1980 I want the sleeping uC to be triggered by the mic interrupt.
-
-
Hey y'all,
Is it possible to connect a simple two-pin electret microphone to an Espruino microcontroller and program the uC to wake on a loud sound, like a clap or snapping of a finger? I can't find any resources regarding microphones in the Espruino website, or anywhere else. I don't think it would be hard at all, I'm just not sure if there's a way yet. I'm using an MDBT42Q module, if it helps.Thanks!
-
Hey Gordon,
The watch went for five days until I implemented the music control function. Then it died in about 10 minutes. I'm estimating the actual battery life is about a week, assuming I check the time about five times an hour. My firmware version is 2.03, which I believe is the newest.
Also, the battery was completely drained very shortly after the LEDs went dim. Usually I can guess a few culprits for my electronics issues but for this one I'm completely blank. -
https://github.com/iamericmin/Time-Machine-Mk.-IV/blob/master/clock_mk4.js Here's the code. I put it in a link to make my response more concise.
I have two seven segment LEDs and five 1206 SMD LEDs, all blue. I know, it's quite a load for the tiny battery. I'm only an amateur so I'm not familiar with the term "duty cycle." I've heard it before but never understood what it was. I just keep all the LEDs on full brightness whenever they are activated. Since it's a watch, they LEDs turn on for about two seconds when a button is clicked. I multiplexed the segments so there's also some fast computation/timing going on too. The button is clicked I think about 5 times an hour, which means the LEDs are activated for 10 seconds an hour, or 240 seconds(4 minutes) a day.
I thought NRF52 modules automatically went to deep sleep?
-
Hi y'all,
I have a custom PCB designed for the MDBT42Q module(it's a wristwatch). The whole thing's powered by a 12mm CR1225 coin cell. I've been doing some battery life tests and today was the fifth day on the same battery.I decided to implement the Bluetooth HID function so that my watch can allow me to control music hands-free. However, after uploading the code and testing things out, the battery died about 10 minutes later. I thought it was because my battery just happened to be low when I added the new function. So I put in a new battery, and it was drained in less than an hour.
Can someone please tell me what I'm doing wrong? I believe there's a reason it's called Bluetooth Low Energy...
EDIT: So I found out the battery's still alive and my smart devices can still connect to my watch. The hands-free control still works. However, none of the LEDs on my watch can light up.
Here's the code I used for the hands-free music control function:
var controls = require("ble_hid_controls"); NRF.setServices(undefined, { hid : controls.report }); setWatch(function(e) { var len = e.time - e.lastTime; if (len > 0.3) { controls.next(); } else { controls.playpause(); } }, BTN, { edge:"falling",repeat:true,debounce:50});
Sorry if things sounded a bit confusing, I'm Korean so English is not my first language.
-
-
Thanks. I'm buying a couple for a custom PCB I designed, and I was deciding whether I should buy pre-loaded ones from your store or non-official ones from somewhere else. I'm going with the first option :)
My card got declined a few times and I got it fixed, but now I can't buy it and Paypal tells me "your card was declined too many times." Do you know how long I have to wait? -
No, I used the regular MDBT42Q firmware from Gordon. I didn't build a custom one. Would enabling the crystal draw more power? Also I don't think I have my serial pins high but I'll check.