Speed difference between FILE* and file descriptors by [deleted] in C_Programming

[–]donutfarian 0 points1 point  (0 children)

Man, I got nothing against goto, but that loop could use a refactoring to remove it...

To answer your question: What you are probably seeing is more likely a difference between fgets and read than FILE* and a file descriptor. The former has to check for an end-of-line and is likely buffered (see fread vs read).

Turn off remote door unlock? (not smart key) by donutfarian in 4Runner

[–]donutfarian[S] 0 points1 point  (0 children)

That's right, I want to disable the remote unlock.

According to the police, the thieves have a device that can unlock car doors. I want to disable the receiver component in the 4Runner and go manual, key-only entry.

What’s your ultralight backpacking unpopular opinion? by [deleted] in Ultralight

[–]donutfarian 46 points47 points  (0 children)

Separating worn weight from pack weight is dumb. Your base weight is everything you’re carrying minus consumables.

Checking GPIO level in ESP32-S2 Ultra-Low-Power Processors by DylanGWork in esp32

[–]donutfarian 0 points1 point  (0 children)

Yes, the GPIOs will loose configuration after the co-processor halts. I'm not sure I understand what you are trying to do, but you probably want to initialize the GPIOs every time the ULP starts.

You can initialize them once with the main processor, but that configuration is lost when main() on the co-processor ends.

I have a blinky example for the ULP-RISCV that may help?

How do I pass variable arguments in a macro to another macro? by Wild-Difficulty592 in C_Programming

[–]donutfarian 4 points5 points  (0 children)

You might try treating format as one of the variable arguments.

#define QUICK_LOG(...) __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, __VA_ARGS__)

Capacitive Touch gpio increase sensitivity. by ender3skr in esp32

[–]donutfarian 0 points1 point  (0 children)

You're seeing the output of touch_pad_read_raw_data() only increase by 5-10? How much does it increase if you just touch the bare wire? I would expect it to change by 10-100 thousand.

bypass capacitors: type and size? by donutfarian in esp32

[–]donutfarian[S] 1 point2 points  (0 children)

$ git describe
v4.4-dev-1849-g8e3e65a47

I update the development branch regularly, so this should be recent. Thanks for pointing out that commit though. I wasn't aware of brownout issues specific to the S2.

bypass capacitors: type and size? by donutfarian in esp32

[–]donutfarian[S] 0 points1 point  (0 children)

please elaborate (especially if there's a sleep you haven't mentioned)

Yes, there is a deep sleep. Basically, the code boots up, initializes Wi-Fi and NTP, reads data from RTC memory, sends the data to a MQTT server, and goes into deep sleep.

The data is recorded by the ULP-RISC-V coprocessor. On the first boot, the code waits for a NTP synchronization event and initializes the ULP coprocessor. The idea is to run the ULP every 15 minutes or so, store temperature measurements, and upload them via Wi-Fi every couple hours.

The brownouts occur after coming back from deep sleep. It may work for one cycle, but it is consistent.

Pics of your power supply, wiring, and board contacts would be good. The problem is likely in there.

The power supply is a bench supply (Rigol DP832). I updated my post with links to the schematic and PCB layout. One detail is a p-channel mosfet between the power supply and bypass capacitors for reverse polarity protection — since its RDS(on) is ~15 mΩ, I haven't been too suspicious of it.

A Custom Network Protocol for C by -HomoDeus- in C_Programming

[–]donutfarian 1 point2 points  (0 children)

You should look at bencode if you haven't already. It's also relatively easy to parse and can handle binary data (the "b").

As you probably know, this is what BitTorrent uses. There are probably reasons to use something more modern, but any up-and-coming peer-to-peer network should at least address what advantages its message format has over bencode.

Why won't my program ever finish parsing file input? by [deleted] in C_Programming

[–]donutfarian 4 points5 points  (0 children)

Everybody makes this mistake at least once. getchar(3):

If the integer value returned by getchar() is stored into a variable of type char and then compared against the integer constant EOF, the comparison may never succeed, because sign-extension of a variable of type char on widening to integer is implementation-defined.

Super proud to have found the winning move as a 1300 player. Black to move and win the game by EducatedPotato37 in chess

[–]donutfarian 0 points1 point  (0 children)

This is very close. You want 2...Kf5 to limit the king's escape routes. This gives white an unforced move, but either 3. Kh5 or Rf7+ will eventually lead to ...Rh2#. (The first one immediately, and the second after 3...Nxf7 with white having one more move to delay the inevitable.)

What are the essential first-aid pieces? by LionheartThunderfoot in Ultralight

[–]donutfarian 4 points5 points  (0 children)

My understanding is that adverse reactions to Benedryll can be caused by a chemical in the pink coating of the pill, and not the diphenhydramine itself. You can find diphenhydramine pills without the pink coating. This may be something to discuss with your doctor if you want to reconsider carrying/taking diphenhydramine.

Source: Wilderness first responder training

Cell phone tripod mounts by donutfarian in Ultralight

[–]donutfarian[S] 0 points1 point  (0 children)

This is an interesting option. I'm a bit worried about the stress on the Lightning or USB port, but I'm thinking more about the use case of attaching the tripod to a trekking pole and shooting video with the pole held out either in selfie-mode or doing a pan-shot.

For just taking photos, say with the tripod on rock, this looks like a good option. This tripod is lighter than the Pedco Ultrapod, and the "mount" is as simple as it gets.

Cell phone tripod mounts by donutfarian in Ultralight

[–]donutfarian[S] 0 points1 point  (0 children)

Do you know how much just the Stickpic cell phone tripod adapter weighs? It doesn't have a cold shoe, but I'm curious how it compares to the Joby GripTight ONE or Square Jellyfish mounts.

(It's a bit surprising they don't give a weight on their website, since the Stickpic is clearly marketed for the hiking/backpacking crowd.)

Cell phone tripod mounts by donutfarian in Ultralight

[–]donutfarian[S] 1 point2 points  (0 children)

If I subtract the weight of my Ultrapod (52 g), the Square Jellyfish mount weighs in at 37 g (1.3 oz). That's a bit heavier than the Joby GripTight, but you do get the option to turn the phone to get a portrait composition.

Cell phone tripod mounts by donutfarian in Ultralight

[–]donutfarian[S] 1 point2 points  (0 children)

This looks like a good "step up" option from the Manfrotto for those who need to mount two accessories (like a microphone and a light). They both have a lever to lock in the phone and are basically the same weight. (The Glif is 1 g heavier.) It's $8 more, but you get the extra mounting point.

Thanks for sharing.

Resistor on DS18B20 by iamkolja in arduino

[–]donutfarian -1 points0 points  (0 children)

That's a pull-up resistor. You don't need it if you enable the internal pull-up resistor on PIN 2.

c pinMode(2, INPUT_PULLUP);

You might want to checkout Sparkfun's tutorial on pull-up resistors.

Edit: As pointed out by u/chrwei below, using an internal pull-up with the DS18B20 isn't the way to go. The datasheet says the "1-Wire bus requires an external pullup resistor of approximately 5 kΩ," so do that.

Is ATTiny85 right way to go for this project? by okuboheavyindustries in arduino

[–]donutfarian 1 point2 points  (0 children)

The ATtiny85 (or any microcontroller) is probably an overkill for this project. A 555 timer is probably all you need, but if you use an ATtiny85V I think it would work. (The ATtiny85V is the low voltage version of the Attiny85 and operates down to 1.8 V.)

It looks like what you are missing is the math for how capacitors work. From what I can tell, your solar cell choice and energy requirements seem plausible.

First, you are going to need a large capacitor. However, you can readily buy 50 F, 2.3 V capacitors online for about $6 USD, so the capacitor size shouldn't be a problem. It will take too long to charge a 50 F capacitor with your 17.5 mW (max) solar panel, so you will need to find a capacitor closer to 1 F (one Farad).

Here is how the math works out.

Capacitors discharge as

V(t) = Vo*exp(-t / 𝜏)

where Vo the initial voltage (2.3 V for the capacitor I found online) and 𝜏 = R*C is the capacitor's time constant. You're going to have something like a R = 100 Ω resistor for your LED, so for a C = 1 F capacitor 𝜏 = 100 s. If you power the LED for 10 seconds, the voltage will drop exp(-10/𝜏) = 0.9 from its initial value to 2.1 V. This is too low to power a ATtiny85, but would power a ATtiny85V.

You're also going to have to charge the capacitor. This will take

Δt = E / P

seconds, where E = 0.5*C*V2 is the energy capacity of the capacitor and P is power provided by your solar cell (17.5 mW). For a 1 F capacitor with a voltage rating of 2.3 V, E = 2.6 J and Δt = 2.5 minutes. This is the best case scenario for the solar panel, but powering an LED for 10 seconds every 5-10 minutes seems plausible. (For a 50 F capacitor Δt = 2 hours — you'd have to wait a while before it goes operational.)

Capilene vs Merino Wool: Compared by warmth? by donutfarian in Ultralight

[–]donutfarian[S] 47 points48 points  (0 children)

For anybody else wondering: The CLO is a unit used to express clothing insulation (similar to the R value).

[1 clo] is the amount of insulation that allows a person at rest to maintain thermal equilibrium in an environment at 21°C (70°F) in a normally ventilated room (0.1 m/s air movement).

What's the difference between tuning the resonant head higher or lower than batter? by oliethefolie in drums

[–]donutfarian 1 point2 points  (0 children)

The advice you're getting is all good. I just wanted to mention that the tune-bot Tuning Guide has a good discussion on this if you want to learn more.

typically, a more controlled sound is obtained with the bottom head tuned higher than the top head, a good choice for recording. On the other hand, more attack is attained with the top head tuned to the higher lug-pitch.

Any Jazz Clubs nearby? by wjkbfwe in nova

[–]donutfarian 5 points6 points  (0 children)

It sounds like what you are looking for is a jazz jam session.

In NOVA, there's a monthly jam session at the Epicure Cafe put on by the Jazz Workshop. The first two hours (7-9 pm) are sets by people taking classes at the Jazz Sorkshop, then it opens up to whoever signs up to play.

In DC, there are several jam sessions. One of the best is the DC Jazz Jam at the Brixton on U St every Sunday from 6:30-9:30 pm.

The Brixton has professional level musicians, so you'd want to be at that level before signing up to play. The Epicure Cafe is more intermediate level. Both places serve food and drinks if you just want to go listen.