Recent Posts

1
Wirelings / Re: Wireling IR Emitter and IR Detector Example Scripts - Help
« Last post by lcpalm on May 16, 2022, 05:46:51 PM »
Hi Rena,

Thanks SO much -- this was super helpful! I'm getting output that is not quite as expected but close, as you said.
Still have some work to do to figure out  what is going on in the logic of this loop and of IR codes themselves, and the purpose of the interrupts, but it's much clearer now.
At least it is very good to confirm that the IR-E and IR-D are both working - are both sending and receiving codes!

Much appreciated,
Linda
2
Wirelings / Re: Using Wireling IR-Emitter and Receiver to detect beam breaks?
« Last post by lcpalm on May 16, 2022, 05:41:33 PM »
Hi Rena,

Thanks again -- I was able to get the code you posted here working on my device, thank you.
It turns out that it only flashes when the beam-break is ended (and only flashes the one time, at the end of each break, instead of giving a continuous on-or-off type signal).

It looks like this is how the IR Detector in the Wireling is designed to work. It's meant to receive IR codes, and it actually filters continuous inputs.

There are some workarounds on the link I posted for getting this kind of device to work as a beam-break but it looks like they require a delay of 60-90ms while I need less than 20ms data rate, so, I'll look for another IR-detector and hook it up to the Wireling.

Thanks very much again for your help!

(ps I deleted my comment here with a mess of code that wasn't working, hope that was OK to do - seemed better not to leave it as it was just confusing.)

3
Wirelings / Re: Wireling IR Emitter and IR Detector Example Scripts - Help
« Last post by lennevia on May 16, 2022, 12:00:37 PM »
Here's some background on what the interrupts(); and noInterrupts();  code does: https://www.arduino.cc/reference/en/language/functions/interrupts/interrupts/

The example doesn't work as is, but when the noInterrupts(); are commented out, it will work with the mute code.  I hope that helps get you on the right track.

Cheers,
Réna
4
Wirelings / Wireling IR Emitter and IR Detector Example Scripts - Help
« Last post by lcpalm on May 13, 2022, 06:47:55 PM »
Hello,
The Wireling IR Emitter and IR Detector Example scripts come as two separate scripts; I've tried to combine them into one, by putting the Receiver code into a function,
and calling it after the Emitter sends in the main loop.
But it looks like it never reads the sent IR-code, ie  if (irrecv.decode(&results))  is never true... Not sure what I am doing wrong, can you help?
thank you!!!

 /************************************************************************
   IR Emitter Wireling Example
   IR Receiver Wireling Example
   Copied from: https://learn.tinycircuits.com/Wirelings/IR-Emitter_Wireling_Tutorial/
               https://learn.tinycircuits.com/Wirelings/IR-Receiver_Wireling_Tutorial/
/// Combined to transmit and receive on same device 5/13/2022 - Never reads?
 ************************************************************************/

#include <IRremote.h>
#include <Wire.h>
#include <Wireling.h>

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

// Define codes as 32 bit unsigned integers [///Edit: fewer codes, for simplicity]
uint32_t powerCode = 0x10AF8877;
uint32_t muteCode = 0x10AFF00F;

// Receive and transmit can be done on any IO pin. Pick A0-A3 for Wireling ports 0-3.
int TX_PIN = A0;
int RECV_PIN = A3; /// added from WirelingIRReceiverExample

IRsend irsend(TX_PIN);
IRrecv irrecv(RECV_PIN);

void setup(void) {
  SerialMonitorInterface.begin(9600);
  Wire.begin();
  Wireling.begin();
  while (!SerialMonitorInterface && millis() < 5000); //This will block for 5 seconds or until the Serial Monitor is opened on TinyScreen+/TinyZero platform!

  irrecv.enableIRIn(); // Start receiving data  /// added from WirelingIRReceiverExample
}

void loop() {
  SerialMonitorInterface.println("Sending powerCode!");
  noInterrupts();                                               /// [from example code; I don't know what the interrupt code does]
  irsend.sendNEC(powerCode, 32);
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  interrupts();                                                    /// [from example code; I don't know what the interrupt code does]
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  delay(1000);
  SerialMonitorInterface.println("Sending muteCode!");
  noInterrupts();
  irsend.sendNEC(muteCode, 32);
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  interrupts();
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  delay(1000);
}

/// void loop() {} from WirelingIRReceiverExample code put into below function:
void receiverExampleCode() {
  /// add println
  SerialMonitorInterface.println("into Receiver function");
  decode_results results;
  if (irrecv.decode(&results)) {
    irrecv.resume(); // Receive the next value
    if (results.decode_type = NEC && results.bits == 32) { //Check if there's a match for our expected protocol and bitcount
      if (results.value == powerCode) {
        SerialMonitorInterface.println("powerCode received!");
      } else if (results.value == muteCode) {
        SerialMonitorInterface.println("muteCode received!");
      } else {
        SerialMonitorInterface.print("Unrecognized code! ");
        SerialMonitorInterface.println(results.value, HEX);
      }
    } else {
      SerialMonitorInterface.print(results.decode_type);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.print(results.bits);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.println(results.value, HEX);
    }
  }
}

5
Wirelings / Re: Using Wireling IR-Emitter and Receiver to detect beam breaks?
« Last post by lennevia on May 10, 2022, 06:14:44 PM »
Hiya,

I think I got the example working. It looks like the library changed the way it initiates the IRsend object since that blog was posted, so you would want to use:
Code: [Select]
IRsend irsend(PIN_IR);rather than:
Code: [Select]
IRsend irsend;
Here's the full modified example I got working with some comments. I uploaded this on a WirelingZero with ports 1 and 2. The status LED flashes when I move the Emitter away, so I believe it is working as expected, but I'm not exactly an expert on beam breaking, so let me know how it works for you!

Code: [Select]
#include <IRremote.h>

#define PIN_IR A1     // This is the IR Emitter on port 1 of the Wireling adapter
#define PIN_DETECT A2 // This is the IR Receiver on port 2 of the Wireling adapter
#define PIN_STATUS 13 // The status LED - normally pin 13 for the majority of Arduino boards

IRsend irsend(PIN_IR);
IRrecv irrecv(PIN_DETECT);

void setup()
{
  pinMode(PIN_DETECT, INPUT);
  pinMode(PIN_STATUS, OUTPUT);
  irsend.enableIROut(38);
  irsend.mark(0);
}

void loop() {
  digitalWrite(PIN_STATUS, !digitalRead(PIN_DETECT));
}

I think this example could be improved with some output in the Serial Monitor so we know exactly what's happening since the status LED doesn't give me 100% confidence that I understand what signal's being picked up.

I hope that helps.

Cheers,
Réna
6
Previously, I've set up a switch on TinyZero using an external pull-up resistor; then, more simply, have connected it using the internal pull-up resistor with the command:
  //Configure pin 3 as an input and Enable the internal pull-up resistor:
  pinMode(3, INPUT_PULLUP);

The switch I have has three poles, one on the left and two on the right; soldered to TinySheild GND and pin 3 like so:
  GND -------> center pin on switch
  pin 3 ------> rightmost pin on switch
When switch is ON it connects the center and rightmost pin. I left the leftmost pin open.

This seems to work fine. I'd like to know if this would work for an input sensor.?

I have a sensor (simple infrared light detection, IRD) that normally requires a 10K ohm pull-up resistor; it is soldered to VCC (power), GND, and analog port A0 on TinyShield, with the external 10k resistor soldered into the circuit as follows:

VCC (power) -----> 10k ohm -----------> (+) IRD (-)   ---------> GND
                                                      |
                                                        ----- >  A0

It's paired with an IR emitter LED hooked up with a 220 ohm resistor:
VCC (power) -----> 220 Ohm ----------->(+)  IRE  (-)   ---------> GND

This gives an analog signal at A0, and I use this to tell when the light between IRE and IRD is blocked. So I could also treat this as a discrete signal LOW/HIGH.
They are https://www.sparkfun.com/products/retired/241

Question 1: Could I connect this without any external resistor to TinyZero e.g. pin 3, if I enable the pull-up resistor with  pinMode(3, INPUT_PULLUP); ?
VCC (power) -------------> (+) IRD (-)  -------> 3

or should it be
3 ----------------------------> (+) IRD (-) --------> GND

or ?

It seems like this should work but am hesitant! I don't want to damage the TinyZero...

Question 2:  there's no way to not use the 200 ohm resistor for the IRE LED, I take it? That is just outputting the IR light continuously.

Thanks very much for your help!
(I'm also interested in converting this to Wirelings but those are separate questions.)
7
General Discussion / Re: tinyscreen+ stuck in boot loader mode
« Last post by lennevia on May 09, 2022, 11:53:03 AM »
I don't have any other helpful ideas for debugging since it sounds like there's a hardware issue. Please get in touch with us and we should be able to get you a replacement. Reach us through our contact from: https://tinycircuits.com/pages/contact-us

Thanks,
Réna
8
General Discussion / Re: tinyscreen+ stuck in boot loader mode
« Last post by hoguech on May 07, 2022, 07:11:10 AM »
Hi Réna,

Thank you for the response. Unfortunately this did not work either. I went through the entire sequence (including the reset of the board). Used only the tinyscreen board and loaded the base example. According to the arduino IDE it compiled and uploaded successfully. When the upload completed the screen flickered briefly, then went straight back to the bootloader mode screen. Same as before.

Any other thoughts or ideas?

Thx,
Chris
9
Wirelings / Using Wireling IR-Emitter and Receiver to detect beam breaks?
« Last post by lcpalm on May 06, 2022, 06:55:25 PM »
Hi TinyCircuits,

Question: Is it possible to use the Wireling IR-Emitter and Wireling IR-Receiver to detect simple beam breaks using a TinyZero?

I'm trying to convert a circuit I built using a TinyZero, to Wirelings. This had used a simple non-wireling IR-emitter LED and IR-detector pair  (https://www.sparkfun.com/products/retired/241), soldered in to a tiny shield with appropriate resistors; the IRD required a 10kOhm  pull-up resistor. (It reports a beam break when you block a porthole with an IR illuminator-detector pair on either side, at a sample rate of about 20ms, and writes to microSD.)

I was able to get this working with the same resistors by cutting a Wireling cable and soldering the old IR-emitter and detector up with their same appropriate resistors inline (including the 10k Ohm pullup for the IRD and a 220ohm resistor for the IRE) to the Wireling cable. This uses the Wireling library, but doesn't use the IRremote library.

But it would be much nicer to use the actual Wireling IR Emitter and Wireling IR Receiver and avoid the need to solder in resistors!

I've gotten the Wireling IRE and IRD to send and receive "IR codes" from your tutorial examples on my TinyZero (although the interrupts were a bit of a mystery),  but can't seem to get the IRD to recognize the mere presence or absence of a signal from the IRE  - and am not even sure if have managed to send the signal in that mode.

 I'm attempting to adapt this code :
http://www.righto.com/2010/03/detecting-ir-beam-break-with-arduino-ir.html

One problem : The Wireling IRD TSOP572 datasheet says it suppresses "Continuous signals at any frequency", which that page says will prevent the code from working -- There's some workarounds for this in some comments on that page but I have not been able to get them to work. I don't have a good enough understanding of how the IRremote library and Wirelings work together to adapt them to get the IR-emitter to simply send a continuous signal and the IR-detector to simply detect its presence or absence.

I'd be grateful for any suggestions!

(edit: had another question about pull-up resistor use, posted that separately).


10
Thumby / Re: Battery
« Last post by DarkGizmo on May 06, 2022, 06:42:56 PM »
Once again I answer my own post from a discord answer by JasonTC

Code: [Select]
import thumby
from machine import ADC

adc = ADC(26)

# Average when unplugged is around 3700
# Average when plugged is around 4000
charging_threshold = 38500
average_charging_value = adc.read_u16()

while True:
    thumby.display.fill(0)
   
    average_charging_value = (adc.read_u16() + average_charging_value) // 2
    if average_charging_value > charging_threshold:
        thumby.display.drawText("Charging", 0, 0, 1)
    else:
        thumby.display.drawText("Not charging", 0, 0, 1)
   
    thumby.display.update()
SMF spam blocked by CleanTalk