Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - lcpalm

Pages: 1
1
Hi Réna,

Thank you so much! That was it. It works perfectly now.

Phew :)

May I ask, just to be clearer:
-- Can I leave out the line, #include <Wire.h> , in my code?
   (and I don't need to run Wire.begin(); in my setup?)
-- Can/should I include a line:
    Wireling.selectPort(0);   ? or in my case Wireling.selectPort(A0);  ?

As this example,
https://learn.tinycircuits.com/Wirelings/Hall-Effect_Wireling_Tutorial/

includes these lines:

Code: [Select]
#include <Wire.h>               // For I2C communication
#include <Wireling.h>           // For Interfacing with Wirelings

// and then in setup:

Wire.begin();

 // Enable & Power Wireling
 Wireling.begin();
 Wireling.selectPort(0); // This must match the port the Wireling is connected to
                          // on the Adapter board

I am not using I2C, so maybe better to leave out the #include <Wire.h>
But I'm not sure about why I do or do not need Wireling.selectPort(0) or (A0).

Thanks again,
Linda

2
Hi,
I have a TinyZero circuit that works as expected when connected using Proto Terminal Blocks shield, or using an Arduino UNO.
But it does not work when connected in the same way with Wirelings....! I'm trying to use GND, 3v3, and INT wires, along with an external pull-up resistor to get analog voltage values off my sensor.

Does Wireling have some internal processing that prohibits using this analog input in this way? can I turn that off? or am I doing something wrong?

My code:
Code: [Select]
//TerminalBlocksVsWireling
// 2022-09-15

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

// boilerplate code to make serial monitor work with either arduino uno or tinycircuit's tinyzero
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

#define irdPin A0        // Corresponds to PORT# of Wireling used; or A0 of TerminalBlocks or Arduino UNO
int readValue = 0;       // the IR sensor value, analog

void setup() {
  SerialMonitorInterface.begin(9600);

  // Start with a 3s delay, lighting external green LED for 3s.
  pinMode(LED_BUILTIN, OUTPUT);     
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(3000);                     
  digitalWrite(LED_BUILTIN, LOW);   

  SerialMonitorInterface.println("");
  SerialMonitorInterface.println("TerminalBlocksVsWireling");

  pinMode(irdPin, INPUT);

}

void loop() {
  readValue = analogRead(irdPin);

  SerialMonitorInterface.print("IRD pin read value: ");
  SerialMonitorInterface.println(readValue);

  delay(500);

}

I took a Wireling cable and stripped the ends of the GND, 3V3, and INT (analog) and soldered them to wires to plug into a breadboard for testing.

On TerminalBlocks: I connect GND, VCC, and A0 to my protoboard.
On Wireling: I connect GND, 3V3, and INT from port 0 to my protoboard (equivalent).

The board has a couple of diodes and resistors as follows:
1. IR-Emitter diode with external current-limiting resistor: Just emits IR light:
VCC --------- 220ohmResist -------(+)anode_IRE_cathode(-)--------- GND


2. IR-Detector diode with external pullup resistor, connected to A0 between the resistor and the IRD:

VCC -----10kResist ---/-----(+)anode_IRD_cathode(-)------------------GND
                                 /
                              A0

So,
When IRD is active (detects IR light), voltage on analog input A0 should be low voltage,
 When IRD is inactive (detects no IR light), voltage on A0 should be a higher voltage.

Results:
Works perfectly with TerminalBlocks shield on TinyZero, or with Arduino UNO:
 Low ~53            when IRD gets IR light
High ~700-800  when IR light blocked (using UNO 3.3V, High is ~500; that's fine)

But with Wireling shield, same connections: Not working!
Output is  ~1 or 2, or 3   when IRD gets IR light
and is also  ~1 or 2, or 3   when IR light blocked

I know that I can set an *internal* pull-up resistor on the analog input A0, but we don't want this -- we want to get an analog voltage value.
I found this earlier forum post about analog wireling use but it did not help here.  http://forum.tinycircuits.com/index.php?topic=2419.msg5307#msg5307

Datasheets for the  IRE and IRD diodes: https://www.sparkfun.com/products/retired/241

Thank you for any help!!

3
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

4
Hi Rena,

Thanks again -- I was able to get the code you posted here working on my device, thank you.
It turns out it flashes only 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 (according to the datasheet).

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.)


5
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);
    }
  }
}


6
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).



8
Hi Réna,

I am also trying to work with the onboard RTC on my TinyZero .
You mention here that "I attached a zip file of the program that you can use with the TinyZero to work with the onboard RTC" .
I don't see it here, can I get a copy?

Thank you!

Linda

"We have been meaning to publish a more general RTCZero library example tutorial with our products using the SAMD21 processor (TinyZero, TinyScreen+, RobotZero, WirelingZero), but the only current published tutorial is the extended TinyScreen+ one that includes more about sleep mode and interrupts (very popular topic): https://tinycircuits.com/blogs/learn/tinyscreen-external-interrupt-sleep-mode

On the bright side, we have the program ready to go for testing. I attached a zip file of the program that you can use with the TinyZero to work with the onboard RTC. You will just need to download that program and install the RTCZero library: https://www.arduino.cc/reference/en/libraries/rtczero/

Let me know how the program works for you!"

9
For what it's worth... I hooked up the sensor to A2 instead of A5 and it worked fine.
Not sure what is wrong (is A5 not an analog input?) but will go ahead and use A2.


10
Hi,
I'm having trouble and not sure why: Have a circuit set up with a sensor attached to A0, and it reads fine; but if I attach the sensor to A5, it does not report the input.

Here is my code:

---------------------------------

#include <SPI.h>

int readValue1 = 0;
int readValue2 = 0;

// setup for TinyZero
#if defined(ARDUINO_ARCH_SAMD)
  #define SerialInterface SerialUSB
#else
  #define SerialInterface Serial
#endif

void setup() {
  SerialInterface.begin(9600);
  delay(3000);

}

void loop() {

  String dataString = "";

  readValue1 = analogRead(A0);
  readValue2 = analogRead(A5);

  dataString += String(readValue1);
  dataString += ",";
  dataString += String(readValue2);

  SerialInterface.println(dataString);

  delay(1000);

}

----------------------

My circuit is:
 VCC ---> 220ohm ---> IR-emitter ---> GND
VCC ---> 10k ohm ---> A0 [or A5]
                                |--> IR-detector ---> GND

This works as expected when connected to A0: it reports low values when there is IR light striking the IR-detector, and reports high values when the light is blocked. That is, in serial monitor, we get sensor value in A0, and nothing meaningful in A5, as expected:
A0, A5
42,332
43,370
43,367
43,357
361,382 <-- when light blocked
349,373 <-- blocked
340,354 <-- blocked

But when connected to A5, it doesn't report sensor value in A5:
A0, A5
361,382
349,373
340,354
321,372
305,368
that is, here the second column should be low; but it never is.

I'm not sure what is wrong here?

Thank you!

11
Hi Réna,

Oh, wow - thank you. To do this I'd need to acquire a much tinier soldering iron than I have.
That looks super challenging.
But might go for it!

Thank you for your help!

12
Hello,

I have a TinyZero project and would like to attach an external power switch (have wires running to a power switch attached on the enclosure of my project).  I bought a little switch, but am not sure how to wire it up to the TinyZero, or if this is even possible?

Thank you!

13
Hi Réna,

Thanks for your response! Yes, it was something with the serial communication --- I set it to have a 3s delay during startup, and that seemed to take care of it.

I do have another question now -- I would like to set up my TinyZero with an external power switch (like, run wires about 2-3" away so that I can have a power switch on the bottom of my little device I'm building, instead of moving the switch on the card itself.) I bought a little switch but am not sure how to hook it up, or if this is possible...

Should I submit this as a separate question?

Thank you!
Linda

14
TinyDuino Processors & TinyShields / Tinyzero won't run off battery?
« on: March 23, 2021, 06:11:44 PM »
Hi, I have a TinyZero circuit built, which runs fine off USB but won't seem to run off battery power.

The battery charges (amber light), but when the USB is removed the system doesn't seem to turn on. It's the 3.7V 150mA Li-Ion battery from TinyCircuits.

The circuit is: TinyZero hooked up to micro SD shield and to protoboard leading to an IR sensor pair, which logs beam-breaks.  It works as expected under USB, incrementing the file name on startup (ie every time it's turned on with the power switch on the TinyZero, or the USB is re-plugged in, it starts a new data log on the SD.) But on removing the USB and trying to run off battery power alone, it doesn't turn on and doesn't write any files.

Not sure how to troubleshoot this.... am new to TinyDuino. Thanks in advance for any help!







Pages: 1
SMF spam blocked by CleanTalk